如果我的链接是外部的模板比工具提示工作良好,但如果它在JQuery模板不工作。我试了很多例子,但没有成功。
下面是代码Js文件中网格加载后
ReloadGrid();
$(".hello").tooltip({
track: true,
delay: 0,
showURL: false,
fade: 250,
bodyHandler: function () {
return $($(this).next().html());
},
showURL: false
});
页<script id="cellTemplate" type="text/x-jQuery-tmpl">
<tr class="gridRowCursor" >
<td class="cellTd ">
<input type="checkbox" id="deleteCb" />
<input type="hidden" id="Id_ + ${Id}" class="idField" value="${Id}" />
</td>
<td class="cellTd">
<input id="index" name="index" class="numberField" type="text" value="${IndexOrder}" />
</td>
<td class="cellTdLeft" style="font-size:11px;">
<a class="hello" href="#">{{html DisplayName}}</a>
<div id="tooltip" style="display: none">
<div>
{{html UrlName}}
</div>
</div>
</td>
<td class="cellTd ">
<input type="checkbox" id="activeCb" {{if Active}} checked{{/if}} />
</td>
</tr>
<tr id="${Id}" class="gridRow" style="display: none;">
<td class="cellTdLeft" colspan="5" style="padding-left: 15px; font-size:11px;">
{{html UrlName}}
</td>
</tr>
</script>
<span class="instructions">Only numeric value is allowed in IndexOrder textbox.</span>
<div class="gridDiv">
<table id="set1" class="gridTable" cellspacing="0" cellpadding="0" >
<thead>
<tr class="gridTitleRow">
<td class="iconLink width36">Delete</td>
<td class="iconLink width60">Sort Order</td>
<td class="iconLink width500">Display Name</td>
<td class="iconLink widthAuto">Active</td>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
像下面这样使用Live。不工作吗?
$(".hello").live("tooltip", function() {
track: true,
delay: 0,
showURL: false,
fade: 250,
bodyHandler: function () {
return $($(this).next().html());
},
showURL: false
});
try $(".hello")。Live ("tooltip", function(){代替$(".hello").tooltip({
因为你的hello class元素在加载时不是dom的一部分,你的代码可能试图连接一些还不存在的东西。live方法将确保将来所有类为hello的元素都能获得工具提示事件。