Mit*_*ont 10 html javascript jquery jquery-ui
我调用了一个javascript函数,它<li>使用文本输入框动态构建,然后放入内部.使用jQuery的Draggable,下拉工作正常,但我无法编辑输入文本框?
function addField(type){
var html = '';
html += '<li class="ui-state-default">';
if(type == 'text'){
html += '<b>Text Field</b><br />';
html += 'Field Name: <input type="text" name="text" id="text"> ';
html += 'Field Size: <select name="textSize" id="textSize' + fRank + '"><option value="small">Small</option><option selected value="medium">Medium</option><option value="large">Large</option><option value="large2">Large 2 Lines</option><option value="large3">Large 3 Lines</option><option value="large4">Large 4 Lines</option></select>';
}
html += '</li>';
$("#sortableFields").append(html);
$(function() {
$( "#sortableFields" ).sortable({
revert: true
});
$( "#draggable" ).draggable({
connectToSortable: "#sortableFields",
helper: "clone",
revert: "invalid",
cancel: ':input,option'
});
$( "ul, li" ).disableSelection();
});
}
Run Code Online (Sandbox Code Playgroud)
我玩了取消选项,但它没有帮助.
你有什么建议?
Poi*_*nty 16
我认为问题在于你.disableSelection()对<li>元素的使用.而不是这样做,把文本(你的东西<input>)放入<span>元素,然后禁用跨度
$('li > span').disableSelection();
Run Code Online (Sandbox Code Playgroud)