Hamza
Hamza

Reputation: 31

update attr value in jquery everytime

guys i'm using a plugin to autoload when i scroll down and this is my jquery code :

jQuery('#displayimagesDiv').scrollExtend(
                {   

                    'target': '#displayimagesDiv',          
                    'url': $('#nexturl:last').attr('href'),
                    'loadingIndicatorEnabled' :  true,
                    'loadingIndicatorClass' : 'loading',
                    'onSuccess' :{}

                }
            );

the HTML code :

<a id="nexturl" href="{{URL::current()}}?page={{$images->page+1}}" style="display:none">#</a>

the problem is when i scroll for the first time it doesn't update the value of the #nexturl:last selector value so i got everytime the old url (example.com/?page=1) instead of (example.com/?page=2) . any help plz .

Upvotes: 0

Views: 85

Answers (1)

tilleryj
tilleryj

Reputation: 14379

Try replacing the 'url' parameter with a function:

jQuery('#displayimagesDiv').scrollExtend(
    {   

        'target': '#displayimagesDiv',          
        'url': function() { return $('#nexturl:last').attr('href'); },
        'loadingIndicatorEnabled' :  true,
        'loadingIndicatorClass' : 'loading',
        'onSuccess' :{}

    }
);

Upvotes: 1

Related Questions