Hopefully this makes sense...
I have a page that loads up a dialog box. The shell of the dialog box actually resides in the HTML of the main page (display:none). In the dialog box I have a partial view loaded up via the following call.
$('.partial').load(url, function (html) { $('.partial')[0].value = html; });
This partial view has two select boxes. When the first one is changed the second should be populated via a .getJason call. That call is below.
$.getJSON(url, function (result) {
var dropList = $("#select");
var options = "";
$.each(result, function () {
options += '<option value="' + this.ID + '">' + this.Name+'</option>';
});
$("#select2").empty().append(options); // doesn't work located on the partial view
$("#test2").empty().append(options); // works located on main page
});
The .getJason call is called via a function with onChange="populateSecondSelect()" since the partial view is loaded after the page is initially loaded (the .on won't work in this situation).
The problem is the part where I am trying to load the options into the second select. The jQuery .append doesn't recognize the element. I know the calls are working because when I try and load the values in the "Test2" on the main page it works.
How can I get the jQuery to recognize the element to .append on that loaded partial view?