admin管理员组文章数量:1327581
I have a select dropdown in which whatever is selected I wish to display the name in the jquery dialog that pops up, problem I am having it that it seems to be caching/keeping the previous value and never changing it.
var scenarioname = '';
scenarioname = $('#FileUploadScenarioID option:selected').text();
$('#dialog-module-add').dialog({
autoOpen: false,
closeOnEscape: false,
modal: true,
resizable: true,
draggable: true,
height: 680,
width: 720,
title: scenarioname
});
Yes, I see this article but putting that code in jsfiddle did not seem to give me what I am wanting Passing Variables in jQuery to Change a Dialog Title
I have a select dropdown in which whatever is selected I wish to display the name in the jquery dialog that pops up, problem I am having it that it seems to be caching/keeping the previous value and never changing it.
var scenarioname = '';
scenarioname = $('#FileUploadScenarioID option:selected').text();
$('#dialog-module-add').dialog({
autoOpen: false,
closeOnEscape: false,
modal: true,
resizable: true,
draggable: true,
height: 680,
width: 720,
title: scenarioname
});
Yes, I see this article but putting that code in jsfiddle did not seem to give me what I am wanting Passing Variables in jQuery to Change a Dialog Title
Share Improve this question edited May 23, 2017 at 11:44 CommunityBot 11 silver badge asked Mar 14, 2013 at 23:02 Tom StickelTom Stickel 20.5k6 gold badges116 silver badges115 bronze badges2 Answers
Reset to default 7Maybe:
$('#FileUploadScenarioID').on('change', function() {
var title = $(this).find('option:selected').text();
$('#dialog-module-add').dialog('option','title',title);
});
Perhaps when you change the option
within select
it's not reassigning the new scenarioname
value. What if you added an event handler for the select to reassign scenarioname
var scenarioname = '';
$("#FileUploadScenarioID").change(function () {
$("#FileUploadScenarioID option:selected").each(function() {
scenarioname = $(this).val();
});
console.log(scenarioname);
});
Got something working here: http://jsfiddle/TEjqM/3/
本文标签:
版权声明:本文标题:javascript - Dynamically change Title of jquery dialog with is not getting cached data from select dropdown - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742169429a2426439.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论