我想知道是否有任何可能的方式來刷新從服務器接收到的json對象的aciTree實例。如何在acitree中重新加載json數據
- 讓我們假設我有一個html輸入字段。
- 用戶鍵入內容並單擊提交按鈕。
- 此輸入用於通過ajax調用從服務器獲取新版本的json樹模型。
工作正常。但是,當我在輸入字段中再次鍵入新值並提交時,aciTree不會反映新值。它仍然顯示舊的json對象數據。
這是我的代碼。
User Name: <input type="input" id="name" name="name">
<input type="submit" value="search" id="call" >
<script type="text/javascript">
$(document).ready(function(){
// Makes the ajax call and fetches the json for the resource tree.
$('#call').click(function(){
$("#tree").aciTree({
\t ajax: {
url: 'treeview/jsp/testplansjson.jsp?sname='+document.getElementById("name").value+',
\t \t }
});
});
// Refreshing the tree view - Destroy and recreate
$('#call').click(function(){
var api = $('#tree').aciTree('api');
api.unload(null, {
success: function() {
this.ajaxLoad(null);
// Triggering the click handler of the Get Tree View button.
// This will make the ajax call again and bind the tree...
$('#call').trigger('click');
}
});
});
// ACI Tree - event handler.
$('#tree').on('acitree', function(event, aciApi, item, eventName, opt) {
switch (eventName) {
case 'focused':
case 'selected' :
// Fired when an item in the tree is selected.
if(item) {
$currStatus.text('Selected - ' + item.context.innerText);
}
}
});
});
</script>
<div id="tree" class="aciTree aciTreeNoBranches aciTreeFullRow" style="width:100%;height:auto;margin:0;padding:0;border-left:0;border-right:0"></div>
請讓我知道是否有任何的方式來實現這一目標。
非常感謝你much.Now預期其工作:) – gihan 2015-02-16 04:56:25