问题描述
在我的网页上,我已经输入了应用的 jquery插件,用于多重选择输入+基于ajax的搜索。因为我需要在浏览器中工作/转发按钮,我需要一些内容(DOM元素)在页面(包含输入与应用的sumoelect)删除并存储到变量。
On my page i have inputs with applied SumoSelect jquery plugin for multiselect inputs + ajax based search. Because i need working back/forward button in browser i need some contents (DOM elements) in page (included inputs with applied sumoSelect) remove and store to variable.
追加后内容从变量返回页面DOM元素看起来不错,但sumsoelect不再工作,我不能使用sumoSelect函数输入,如 reload
或分开
/ 附加
After append content from variable back to page DOM elements are looking ok but sumoSelect not working any more, and i can't use sumoSelect function on inputs like reload
or detach
/ attach
以下是其中负载sumoSelect工作正确,点击删除/添加按钮输入停止工作,在控制台中是:
Here is simplified case on jsFiddle where on load sumoSelect working correct and after click on remove/add button input stops working and in console is:
HTML
<div id="content">
<select id="input" multiple>
<option value="Big Island">Big Island</option>
<option value="Oahu">Oahu</option>
<option value="Kauai">Kauai</option>
<option value="Maui">Maui</option>
</select>
</div>
<button class="add-remove">remove/add</button>
JS
$('#input').SumoSelect({ triggerChangeCombined: true, placeholder: "TestPlaceholder" });
$( document ).on( "click", ".add-remove", function() {
var content = $('#content').html();
$('#content').html('');
$('#content').html(content);
// My try without success
// $('#input').sumo.reload();
// $('#input')[0].sumo.unload();
$('#input')[0].sumo.reload();
});
问题:我可以如何使用SumoSelect功能插入存储的HTML文档?
QUESTION: How i can insert stored HTML do document WITH SumoSelect functionality?
是的,我知道有类似 remove()
元素与类 .SumoSelect
之后,使原始输入可见并重新初始化SumoSelect,但为什么不工作SumoSelect功能? THX
Yes i know is there way something like remove()
element with class .SumoSelect
and after that make original input visible and reinitiallize SumoSelect but why are not working SumoSelect functionality? THX
推荐答案
只需更改 $('。content')。html();
to $('。content')。contents();
这篇关于SumoSelect输入删除/添加(html)不工作最远的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!