conmen
conmen

Reputation: 2417

JQuery trigger an function

I had this jquery idle timeout script implemented into a site, thanks to ehynds for the great job.

Everything is working fine except below part:

onTimeout: function(){
    window.location = "timeout.htm";
},

There is another function which will handle the logout process in the same page, I want the onTimeout will trigger a logout function when the timer is reached, which is like below:

onTimeout: function(){
   // call a logout function here;
},

How can I call the function load inside onTimeout block?

Upvotes: 0

Views: 212

Answers (2)

Chris
Chris

Reputation: 726

If the plugin works as it looks like it should - what you pasted is the function you are looking for. If you want to call a seperate function:

onTimeout: function(){
    anotherFunction();
},

but any code inside there should be called if the plugin is functioning correctly. Test like so:

onTimeout: function(){
    alert('i will put my logout function here');
},

if you dont get an alert dialog after the timeout period.. i would say its a problem with the plugin.

Upvotes: 0

Adil
Adil

Reputation: 148180

you can find the control whose event you want to trigger.

onTimeout: function(){
    $('#foo').trigger('click');
}

or You can call function staightway.

onTimeout: function(){
    SomeFunction();      
}

Upvotes: 1

Related Questions