1

Since I started this new webshop for a friend to launch, which still in progress, I'm using the so called "jQuery fixedScroll"..

Project online: http://www.merkversterkers.com/klanten/fragma/index.php?p=shop

Everything is fine until this.. When I'm using the scrollplugin, it defines the height of the page, which a good thing..

After pressing the "filter" button the height must be predefined causing a div that will expand, and I'm unable to do that, because the document defines the height when it's loaded..

like the "$(document).ready" function

scrollfunction

$('#scart').scrollToFixed({
   marginTop: $('.topbar').outerHeight() + 30,
   limit: get_limit(),
   zIndex: 999
});

get_limit functon

function get_limit(){
    var products_row = 4;

    var topbar = $(".topbar").height() + 30 
    var filterbar = $(".filterbar").height();
    var products = products_row * 206;

    if( $(".filterexpanded").css('display') == "block" ){
        var expanded = $(".filterexpanded").height(); 
    } else {
        var expanded = 0;
    }   

    var cartheight = $("#scart").height();

    var limit = topbar + filterbar + expanded + products + 130 - cartheight;

    return limit;
}

Can someone give me throw of some code I could try? I would really appreciate all the help..

3 Answers 3

1

Without reading the question you should change this:

limit: get_limit(),

To this:

limit: get_limit,
Sign up to request clarification or add additional context in comments.

6 Comments

hehe, no doesn't work since I'm calling a function and not a variable.. sorry mate
I tried, it usally is something like that though, you wouldn't believe the amount of $('div').click(fun()) quesions we get
i know, thnx for the help anyway..!
@JayRuben: You can try doing a trigger('remove') and then rebind it with the new height
Yes!!! this helped me out.. Trigger remove and rebind will add the new height to the available space.. Thank you so much!
|
1

When you are trying to set a function as a value in an object you should not use the parentheses. When you do, you are basically evaluating the function and it's value will be returned instead of the actual function.

var myObject = {
    myFunction: funkyFunk()
};

function funkyFunc(){
    var funkierFunction(){
        // You COULD do this
    };
    return funkierFunction;
}

But this is what you need...

var myObject = {
    myFunction: funkyFunk
};

function funkyFunc(){
    // You probably want this though    
}

2 Comments

ok, seems good to me.. Based on the answer before .. however.. when I'm calling the get_limit.. it won't recognize the function, maybe some tips left?
Have you put some kind of a console.log or alert in the function to be 100% sure that it's NOT being called?
0

An (untested) idea after looking at the plugin's source:

var scrollToFixedObj = $('#scart').data("ScrollToFixed");
scrollToFixedObj.options.marginTop = get_limit();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.