Results 1 to 1 of 1

Thread: Setting height and width Dynamically using Jquery not reflected. Getting values from

  1. #1
    Join Date
    Jul 2015
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Setting height and width Dynamically using Jquery not reflected. Getting values from

    Step 1. I am dragging and dropping some items in a div.
    Step 2. Item size is auto resizing according to the available space by an auto zoom-out functionality.


    Step 3. Now when I again zoom-in, the width/height of the parent div should adjust to reflect the scroll effect. For that I am setting the width and height dynamically on click of zoom-out/zoom-in buttons.
    Code:
       
         $('#container').css('width','');
        	$('#container').css('height','');
        	var maxlist = max_group_filter('#container');
        	var total_list = list_count('#container')+1;
        	
        	
        	var boxWidth = $('#container').find('.column ').outerWidth()+20;
        	boxWidth = boxWidth * total_list;
        	
        	
        	var boxHeight = $('#container').find('.sortable-item').outerHeight()+20;
        	boxHeight = boxHeight * maxlist;
        	
        		
        	$('#container').css('width',boxWidth);
        	$('#container').css('height',boxHeight);
        if(scrollbar=="new"){
        		updateScrollbar('#container', 'new');
        	}else {
        		updateScrollbar('#container', 'update');
        	}
    My updateScrollbar(), is working fine but the problem I am facing is that when I am clicking on the zoom buttons for the first time, the width and height values are adjusted according to the previous zoom values. It's getting updated on the second click of the zoom button. I tried to remove the zoom cache by using .removeData().
    Code:
    $('#container').removeData('data-zoom');
    But this is not effecting the cache clear.

    Step 4. The Catch I am facing is that when I try to debug the script using Firebug, the values are working fine and thus the scroll works fine. But without debug mode it's again a failure.

    Step 5. I also tried to update the properties using SetTimeout and .done function but failed.
    Code:
        $('#container').find('.column ').each(function(index, element){
        		boxeswidth += $(element).outerWidth() + 20;
        	}).promise().done( function(){	
        		$('#container').css('width',boxWidth);
        	$('#container').css('height',boxHeight);
        	
        	 });
    But above code also failed. The only reason I have understood by far that jQuery is taking the values for zoom functionality from previous state. I am defining the zoom by using "data-zoom" attribute as below.
    Code:
        .droppedArea[data-zoom="1"] .column{
        	transition :all 0.2s ease;
        	width:25px;
        	font-size:0.3vw;
        	line-height:0.1em;
        	margin-right:1px;
        	
        }
        .droppedArea[data-zoom="2"] .column{
        	transition :all 0.2s ease;
        	width:35px;
        	font-size:0.4vw;
        	line-height:0.2em;
        }
    Last edited by Beverleyh; 07-03-2015 at 11:25 AM. Reason: formatting

Similar Threads

  1. Replies: 2
    Last Post: 05-26-2010, 12:44 PM
  2. Change Width & Height Dynamically of Div
    By theflyingminstrel in forum JavaScript
    Replies: 2
    Last Post: 07-17-2009, 11:42 AM
  3. Getting Height of Div Setting Height of iFrame
    By cgweaver in forum JavaScript
    Replies: 1
    Last Post: 05-01-2006, 08:31 AM
  4. Setting a division's height based on Screen Height.
    By xstayxstrongx in forum JavaScript
    Replies: 1
    Last Post: 01-27-2006, 04:15 AM
  5. setting max-width of BODY element in IE
    By wishiwasageek in forum CSS
    Replies: 13
    Last Post: 05-26-2005, 08:33 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •