是否可以将jQueryUI主题(组合框、按钮)添加到动态元素中
例如:插入页面时,动态选择框或按钮(来自ajax响应)应以jQuery UI组合框样式或jQuery UI按钮样式呈现是否可以将jQueryUI主题(组合框、按钮)添加到动态元素中,jquery,jquery-ui,Jquery,Jquery Ui,例如:插入页面时,动态选择框或按钮(来自ajax响应)应以jQuery UI组合框样式或jQuery UI按钮样式呈现 $.get("someurl", function(html){ $("p").append(html); // at this point the selectbox & button should be rendered as // jQuery UI combobox & jQuery UI Button } 已编辑 响应html包含包含文
$.get("someurl", function(html){
$("p").append(html);
// at this point the selectbox & button should be rendered as
// jQuery UI combobox & jQuery UI Button
}
已编辑
响应html包含包含文本字段、选择框和按钮列表的表单
<select name="scope" >
<option value="in">in</option>
<option value="out">out</option>
</select>
<div class="buttonContainer">
<button name="save">Save</button>
<button name="cancel">Cancel</button>
</div>
与jQuery类似,jQuery使用.on()将事件处理程序函数附加到动态元素。以同样的方式,是否可以将UI主题(组合框、按钮)添加到动态元素中
更新:
我猜在加载页面html时(通过ajax)会触发一个事件。
ajax响应就可以了
$.get("someurl", function(html){
$("p").append(html).trigger("uirender");
}
没有比这更好的方法吗?展示一些您正在接收的html示例。如果可能,还有组合框/按钮的外观。
$("body").bind( "uirender", function() {
$("select").combobox();
$("button").button() ;
});
$.get("someurl", function(html){
$("p").append(html).trigger("uirender");
}