場景:我有一個標準的下拉列表,當該下拉列表中的值發生更改時,我想更新tinyMCE控件中存在的另一個下拉列表。asp.net mvc - 如何更新tinyMCE中的下拉列表
目前,它不會是我想要什麼,當我打開網頁(即第一次)......
function changeParent() {
}
tinymce.create('tinymce.plugins.MoePlugin', {
createControl: function(n, cm) {
switch (n) {
case 'mylistbox':
var mlb = cm.createListBox('mylistbox', {
title: 'Inserts',
onselect: function(v) {
tinyMCE.execCommand("mceInsertContent",false,v);
}
});
<% foreach (var insert in (ViewData["Inserts"] as List<String>)) { %> // This is .NET
yourobject = '<%= insert %>'; // This is JS AND .NET
mlb.add(yourobject, yourobject); // This is JavaScript
<% } %>
// Return the new listbox instance
return mlb;
}
return null;
}
});
<%= Html.DropDownList(Model.Record[184].ModelEntity.ModelEntityId.ToString(), ViewData["Containers"] as SelectList, new { onchange = "changeParent(); return false;" })%>
我想到的方式來做到這一點(在ChangeParentFunction)是調用一個控制器動作要獲得一個新的列表,然後抓住'mylistbox'對象並重新分配它,但我不確定如何將它們放在一起。
聲音intreging,但我有點JavaScript的noob,。你能舉個例子嗎? – 2010-01-06 00:20:50
謝謝ZoogieZork,我會再喝一杯咖啡,並給它一個去! – 2010-01-07 21:33:33
我收到一個錯誤:htmlfile:類型不匹配。在「insertsElem.add(optElem,null);」聲明 – 2010-01-07 21:56:31