Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jan 21, 2013 06:54 AM by iluxa.v
Member
40 Points
278 Posts
Jan 20, 2013 03:36 PM|LINK
// binding function on the change event
$("#selectid").live('change', function () {
if ($('option:selected', $(this)).text() == '--Next 50--') {
var currentFifty = (parseInt($(this).val()) - 1);
var upperFifty = parseInt(currentFifty + 50);
var cOptions = '';
for (var i = currentFifty; i < upperFifty; i++) {
if (collection[i].ID != null && collection[i].ID != "undefined") {
cOptions = cOptions + "<option value=" + collection[i].ID + ">" + collection[i].Text + "</option>"; // generating html for options from collection
}
alert($(this).html()); // html is fine before append
$(this).append(cOptions);
$(this).append($("<option></option>").val((upperFifty + 1)).html("--Next 50--"));
var allhtml = ($(this).html()); // html after append is coming fine
$(this).trigger('refresh'); // NOT WORKING AND SELECT IS NOT COMING WITH NEW OPTIONS
});
215 Points
47 Posts
Jan 21, 2013 06:48 AM|LINK
So what exactly does not working, the append or the "refresh"?
Jan 21, 2013 06:54 AM|LINK
You can also try the following:
$(this).selectmenu('refresh', true);
or
$(this).trigger('create');
dotnet_CH
Member
40 Points
278 Posts
Dynamic append of option into select is not working
Jan 20, 2013 03:36 PM|LINK
// binding function on the change event
$("#selectid").live('change', function () {
if ($('option:selected', $(this)).text() == '--Next 50--') {
var currentFifty = (parseInt($(this).val()) - 1);
var upperFifty = parseInt(currentFifty + 50);
var cOptions = '';
for (var i = currentFifty; i < upperFifty; i++) {
if (collection[i].ID != null && collection[i].ID != "undefined") {
cOptions = cOptions + "<option value=" + collection[i].ID + ">" + collection[i].Text + "</option>"; // generating html for options from collection
}
}
alert($(this).html()); // html is fine before append
$(this).append(cOptions);
$(this).append($("<option></option>").val((upperFifty + 1)).html("--Next 50--"));
var allhtml = ($(this).html()); // html after append is coming fine
$(this).trigger('refresh'); // NOT WORKING AND SELECT IS NOT COMING WITH NEW OPTIONS
}
});
iluxa.v
Member
215 Points
47 Posts
Re: Dynamic append of option into select is not working
Jan 21, 2013 06:48 AM|LINK
So what exactly does not working, the append or the "refresh"?
iluxa.v
Member
215 Points
47 Posts
Re: Dynamic append of option into select is not working
Jan 21, 2013 06:54 AM|LINK
You can also try the following:
$(this).selectmenu('refresh', true);$(this).trigger('create');