jquery-address icon indicating copy to clipboard operation
jquery-address copied to clipboard

$.address.change() is loading twice whenever refresh page

Open pandikamal opened this issue 13 years ago • 7 comments

hi,

whenever i refresh a page, that time $.address.change is loading twice.

$.address.change(function(event){ alert(event.path); });

please help me, how to solve this problem, and also give me a example of internalChange and externalChange event handler

pandikamal avatar Feb 09 '12 13:02 pandikamal

the same problem here but it only occurs in chrome and safari, works perfect in firefox and opera

daberni avatar Mar 13 '12 08:03 daberni

I would double check that the reference to the address plugin is not included twice on the page.

I only suggest because we experienced a similar issue where $.address.change fired twice. It turned out the script file had been included on the master page, but also included on a sub-page by accident.

ashclarke avatar Mar 14 '12 09:03 ashclarke

You can always check the url where the plugin was initialized to event.path and skip the load if they are the same. Works well and does not affect other browsers. You should only use it as a last resort tough, something else must be causing double load.

unknownnf avatar Mar 21 '12 03:03 unknownnf

ie browser is first loading home page and after redirect to original page. what was i mistaken in my codes.

.htaccess files

RewriteEngine On RewriteRule ^index.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . index.php [L]

in footer file having the following code

var init = true, state = window.history.pushState !== undefined;

$.address.state('').init(function(){ $('a.rwajax').address(function(){return getUri($(this).attr('href'));});
}).bind('change', function(event) {

                        var qstring = '';
                         if(event.value != event.path){
                            qstring = '?' +  event.queryString;
                         }

                        var url = $.address.state() + event.path + qstring;
                         if (state && init) {
                            init = false;
                        } 
                        else{
                                 load_page(url+' #inside','div#content_container');
                                 return false;
                        }
              });

please help me, how to initialize the htaccess and $.address().

pandikamal avatar Mar 27 '12 06:03 pandikamal

var init = false;
state = window.history.pushState !== undefined;

$address.init(function(){
    //stuff
}).change(function(){
if (state && init)
   init = false;
else{
   //run code
}

jcldavid avatar May 01 '12 07:05 jcldavid

The jquery address plugin is not designed to work inside the document ready function. Verify your code. See #119.

Also, if you are setting the state option, all URLs but the root will be redirected if you are using a non-HTML5 browser (like IE < 10), causing the change() event to be called twice. I.e., for state('\'), the URL http://host.com/page/ will be redirected to http://host.com/#/page/. See #95.

ericbn avatar Apr 13 '13 02:04 ericbn

I have the same problem, but the reason was that i include jquery.address js file twice :)

rrolla avatar Dec 03 '13 22:12 rrolla