Tuesday, 13 August 2013

jQuery $(document).ready() issue - jQuery 1.7.2

jQuery $(document).ready() issue - jQuery 1.7.2

I have a page on which I am loading a select tag with options that I am
getting from an ajax call to a service. It is working just fine and
loading the select tag correctly. I only want this loading to happen once
when the user first arrives at the page so I put the call to the function
that does this inside the $(document).ready(function call. The problem
that I am seeing is that when the user selects one of the options and then
clicks a button under certain circumstances I pop a dialog (jQuery UI)
telling them they need to take a certain action. The first time this
happen and only the first time the selected option is getting reset
somehow to the first option in the list. I ran in debug many times and
discovered that if this is the first time on the page the selector is
loaded on arrival at the page as is expected but if the dialog gets popped
it is loaded again - only the first time - after that if the dialog gets
popped the reload does not occur and all is well. The abbreviated code:
$(document).ready(function () {
$.fn.LoadStuff();
});
jQuery.fn.LoadStuff = function () {
//load up the select tag with options
};
LoadStuff does not get called anywhere else.

No comments:

Post a Comment