Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to make a particular side div fixed at a particular scroll level.This div have listview.At pageload the fixed div is work well but i click one button and update listview at a time fixed div not worked. How is it possible ? with css or jquery.
Posted
Comments
Jenno Richi 3-Jan-14 6:43am    
Post your code which you used to change the data of the list and the previous list which worked
sarathtamil 3-Jan-14 6:58am    
this javascript to use fix the div

$(function() {
var $sidebar = $("#smallscroll"),
$window = $(window),
rightOffset = $sidebar.offset(),
rightDelta = $("#Footer").offset().top - $("#Header").offset().top - $("#Header").outerHeight() - $("#smallscroll").outerHeight(),
topPadding = 15;

$window.scroll(function() {
$sidebar.stop().animate({
marginTop: Math.max(Math.min($window.scrollTop() - rightOffset.top + topPadding, rightDelta), 0)
});
});

});
sarathtamil 3-Jan-14 7:00am    
i click add button like quantity 1 to 2.Listview have following fields itemname,qunatity,price.listview updated but fixed div go to top of page.

I am guessing one issue here.

You are doing all the changes in jQuery load method. When you are doing any other event and updating any control as you are doing it for ListView, so if you use Ajax UpdatePanel or something for that, so Page would not refresh.

If Page don't refresh, then it will not execute the codes which you have written in load event of jQuery.

So, I would suggest you to put a debugger inside this jQuery load event and see if it is hitting that when you update the ListView. If not, then you have to execute the same code while updating the ListView.
 
Share this answer
 
Comments
sarathtamil 6-Jan-14 1:46am    
page refresh...listview updated but fixed div move to top...
So, you have to execute the same code in while ListView is updated.
sarathtamil 6-Jan-14 2:13am    
onclientclick i call the same function but fixed div move to top and not scroll .fixed div scrolled first time only ,
Can you check if the rendered HTML of that div in browser is correct or not?
I mean compare the HTML of that div when it loads for the first time and when it loads after the ListView update.
I try onclick with register script

C#
ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "MyScript", "scrolltop();", true);

function is


JavaScript
function scrolltop() {
          
            var $sidebar = $('#smallscroll'),
        $window = $(window),
        rightOffset = $sidebar.offset(),
        rightDelta = $('#Footer').offset().top - $('#Header').offset().top - $('#Header').outerHeight() - $('#smallscroll').outerHeight(),
        topPadding = 15;

            $sidebar.css({ 'position': 'fixed','right':'0px'});
 
                $window.scroll(function() {
                  $sidebar.stop().animate({
                  marginTop: Math.max(Math.min($window.scrollTop() - rightOffset.top + topPadding, rightDelta), 0)
                });
            });
        }


it should be work well..thank you Tadit Dash
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900