2013-10-02 35 views
1

動態更改只有一個元素的工具提示標題我有一個tooltipster title屬性一組選項,就像如下:使用tooltipster

<i class="icon-cog settings" title=" 
        <div class='div1' onclick='follow(1,2)'>Content 1</div> 
        <div class='div2' ...>Content 2</div> 
        <div class='div3' ...>Content 3</div> 
                "> 
</i> 

當點擊DIV1,內容dinamically由AJAX結果更新基於以下功能:

function follow(f1,f2) { 
$.get('/exe/add_followers.php?f1=' + f1 + '&f2=' + f2, function (result) { 
    $('.div'+f2).html('content 1 is updated to' + result.newcontent); 
    }, 'json'); 
} 

的問題是,當提示被關閉,頁面一直沒有更新,內容返回到初始值,而不是顯示更新後的值。

我試圖用一個配置選項描述Here

function follow(f1,f2) { 
    $.get('/exe/add_followers.php?f1=' + f1 + '&f2=' + f2, function (result) { 
     // $('.div'+f2).html('content 1 is updated to' + result.newcontent); 
     $('.settings').tooltipster('update', 'content 1 is updated to' + result.newcontent); 
     }, 'json'); 
} 

然而,這種改變DIV1的內容,而刪除其他的div的內容。我如何只更新div1的內容並保持其他內容不變?

== ==編輯

我更喜歡一個解決方案,沒有通過所有設置的div,就像如下:

function follow(f1,f2) { 
    $.get('/exe/add_followers.php?f1=' + f1 + '&f2=' + f2, function (result) { 
     $('.settings').tooltipster('update', ' 
               <div class='div1' onclick='follow(1,2)'>'+result.newcontent+'</div> 
               <div class='div2' ...>Content 2</div> 
               <div class='div3' ...>Content 3</div> 
              '); 
     }, 'json'); 
} 
+0

其與title屬性給出報價的問題。 – ram

+0

@ram你能否詳細說明一下?請! – afazolo

+0

嘗試使用'和「組合轉義標題屬性值以將html轉義爲字符串 – ram

回答

7

我發現這個命令的工作來改變標題:

$('#selectorElement').tooltipster('content', 'new title'); 
相關問題