【发布时间】:2011-09-28 12:44:56
【问题描述】:
我有表单元素的拖放功能。可拖动元素的结构是
<div class="tools">
<ul>
<li class="draggable" >
<div class="control">
<label> </label>
<input type="text" name="txt" value="" />
<span class="controlText"> Text Box </span>
<div class="delete" style="display:none"><sup>x</sup></div>
<div class="properties txtbox" style="display:none">Properties</div>
</div>
</li>
可放置区域有以下代码。元素添加在这个
<div class="editor">
<ul class="sortable" id="leftColumn">
<li style="visibility:hidden" class="ui-state-default">Test</li>
</ul>
</div><!-- editor -->
删除删除后,属性与该元素一起显示。现在,当我单击属性时,我会通过以下方式获得一个对话框
$('.txtbox').live('click', function() {
//get the label
var label = $(this).parent().find('label').html();
$("#textbox_label").val(label);
$( "#dialog-textbox" ).dialog( "open" );
return false;
});
当对话结束时
<div id="dialog-textbox" title="Text Box Properties" style="display:none">
<p>This is the Text Box Properties Form.</p>
<form>
<fieldset>
<label for="textbox_label">Enter Label </label>
<input type="text" name="textbox_label" id="textbox_label" class="text ui-widget-content ui-corner-all" />
</fieldset>
现在我正在做的是当用户在对话框表单中为标签输入一个值时,它应该直接在元素上更新,并且它的标签应该是用户输入的内容
我正在做的更新代码结构是这样的
$("#dialog-textbox").dialog({
autoOpen: false,
height: 300,
width: 350,
modal: true,
buttons: {
"Apply": function(){
//code to update element goes here...
var label = $("#textbox_label").val()
alert("New Label "+label);
// here i need to access the item on which the user clicked
},
Cancel: function() {
$( this ).dialog( "close" );
}
}
});
我应该如何在此更新代码中添加一行,以便将标签更新为用户输入的值???
【问题讨论】:
标签: javascript jquery jquery-ui jquery-selectors jquery-ui-dialog