2011-08-25 79 views
1

如果我的鏈接在模板之外,那麼工具提示工作正常,但是如果它在JQuery模板中根本不起作用。嘗試了很多例子,但沒有成功。JQuery工具提示無法使用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> 

使用活得像下面。不工作?

$(".hello").live("tooltip", function() { 
    track: true, 
delay: 0, 
showURL: false, 
fade: 250, 
bodyHandler: function() { 
    return $($(this).next().html()); 
}, 
showURL: false 

}); 

回答

0

試$( 「你好 」)。住(「 工具提示」 功能(){而不是$( 「你好」)。提示({

由於您的Hello類元素不是當你的代碼被加載時,你的代碼可能會嘗試連接一些還不存在的東西,而實時方法將確保所有未來具有class hello的元素都將獲得添加的工具提示事件

+0

我使用你的建議編輯了我的問題,對嗎?工具提示不支持。你能發佈完整的工具提示代碼嗎? – Pirzada