开发者

jquery.address: $.address.change() runs twice when using $.address.queryString()

$.address.change() runs twice when using $.address.queryString()

if have a url of:

www.example.com

and i run the following code:

开发者_C百科
$.address.change(function(event)
{    
    if(event.parameters['user_id'])
    {
        alert(event.parameters['user_id'])
    }       
});
$.address.queryString('user_id=902715614&user_name=James');

Live example

it alerts the user_id twice

however, shouldn't it only alert once?


It's probably alerting when the page loads (address changed...right?), and then again when YOU change the address.


Without more context it's hard to tell if this makes sense... but should you be calling your function after the DOM is ready like this:

$(document).ready(function () {
  $.address.queryString('user_id=902715614&user_name=James');
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜