views:

46

answers:

3

Hi guys, I'm having a very annoying issue on Firefox 3.6.8. I have this sample plugin:

    (function($){  

    $.fn.test_plugin = function(settings){  

        $(this).load(function(settings){
            alert('ok');
        });
    };
})(jQuery); 

And at the bottom of the html page something like this:

        $(function(){
        $("#image1").test_plugin();
    });

So Basically this should show na alert message fter the pages loads, and it does, except, when you type the url manually on Firefox. If I refresh the page no problem, but on redirect or manually typing the URL it's not. I got no errors and from the firebug everything seems to be fine. This only happens on FF, I got no probs on Safari, chrome, IE.

Any idea why this is ?

thanks

A: 

See the jQuery API entry for load.

.load( url, [ data ], [ complete(responseText, textStatus, XMLHttpRequest) ] )

The first argument to load is a URL. This can optionally be followed by data and a callback function. You did not include a URL in your call to load.

It looks like you're trying to write your first jQuery plugin. If that's the case, I'd recommend reading A Plugin Development Pattern.

I built a Gist based on this that you can also look at.

calvinf
No! The OP is using the load-event, http://api.jquery.com/load-event/
Reigel
Great resource on that link. Thanks
Henrique vilela
Reigel is correct, I didn't see the separate entry for load-event.
calvinf
Also note, if you're trying to run an event after the window has loaded, the best option is going to be $(document).ready(). http://api.jquery.com/ready/
calvinf
A: 

To me it seems that you might have tried to use the jquery load function as a page unload event which is wrong. The load function is for Ajax call which as stated by calvinf requires a URL parameter among other parameters to make the call to.

But read some more and your are well on your way to write jquery plugins :)

XGreen
No! The OP is using the load-event, http://api.jquery.com/load-event/
Reigel
A: 

Ok, thanks for your replies, however I've seem to fixed it.

I've just used

$(window).load(function(settings){

instead of

$(this).load(function(settings){

It fixed the problem and it's working fine on the other browsers.

Henrique vilela