我不确定我做错了什么,因为我之前已经成功了。
我有一些动态添加的HTML代码
...<td><label><input type=\"checkbox\" checked=\"checked\" class=\"Activechk form-contractor-active\" />Active</label></td>"...
然后我执行这个JQuery:$(".Activechk").button();
我收到 "Out of Memory" Error
"Stack Over Flow" Error
这会响铃吗?因为我很难过......
更新:根据火灾错误错误发生在Jquery 1.4.2的第1599行
周围代码:
1594 if ( !eventHandle ) {
1595 elemData.handle = eventHandle = function() {
1596 // Handle the second event of a trigger and when
1597 // an event is called after a page has unloaded
1598 return typeof jQuery !== "undefined" && !jQuery.event.triggered ?
1599 jQuery.event.handle.apply( eventHandle.elem, arguments ) :
1600 undefined;
1601 };
1602 }
答案 0 :(得分:1)
我仔细看了一下,正在编辑这个答案。
按钮功能似乎需要一个带有名为“for”的特殊属性的标签,其值与将成为按钮的输入元素的id相同。
在下面的示例中,我观察到示例输出中的标签/输入关系与此Label不同。
以下示例基于http://docs.jquery.com/UI/Button
中的文档<!DOCTYPE html>
<html>
<head>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<script>
$(document).ready(function() {
$(".Activechk").button();
});
</script>
</head>
<div id="problem">
<label><input type="checkbox" checked="checked" class="Activechk form-contractor-active" />Active One</label>
<br />
<label><input type="checkbox" checked="checked" class="Activechk form-contractor-active" />Active Two</label>
<br />
<label><input type="checkbox" checked="checked" class="Activechk form-contractor-active" />Active Three</label>
</div>
<hr />
<div id="solution">
<p>Inputs can be somewhere else on the DOM but cannot be child elements of labels. The buttons appear where the labels are:</p>
<!-- input elements -->
<input id="inputSolutionOne" type="checkbox" checked="checked" class="Activechk form-contractor-active" />
<input id="inputSolutionTwo" type="checkbox" checked="checked" class="Activechk form-contractor-active" />
<input id="inputSolutionThree" type="checkbox" checked="checked" class="Activechk form-contractor-active" />
<!-- label elements -->
<table>
<tr><td>
<label for="inputSolutionOne">Active One</label>
</td></tr><tr><td>
<label for="inputSolutionTwo">Active Two</label>
</td></tr><tr><td>
<label for="inputSolutionThree">Active Three</label>
</td></tr>
</table>
</div>
</body>
</html>