$.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');
});
精彩评论