EasyUI Forum
April 29, 2024, 01:07:18 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Tab + Treegrid -- $.data(...) is undefined  (Read 7984 times)
mzeddd
Full Member
***
Posts: 223



View Profile
« on: April 01, 2016, 03:51:59 AM »

Hi,

I have the following code

Code:
<script>
function addTab(){
address = 'new.html';
if ($('#docTabs').tabs('exists','New')){
$('#docTabs').tabs('getTab','New').panel('refresh',address);
$('#docTabs').tabs('select','New');
} else {
$('#docTabs').tabs('add',{title:'New',href:address,closable:true});
}
}
</script>
<div id="docTabs" class="easyui-tabs" style="width:700px;height:250px">
<div title="TEST" style="padding:10px">
<input type="button" onclick="addTab()" value="TEST">
</div>
</div>

new.html (short copy of basic.html from treegrid demo)
Code:
<table title="Folder Browser" class="easyui-treegrid" 
data-options="
url: 'treegrid_data1.json',
method: 'get',
rownumbers: true,
idField: 'id',
treeField: 'name'
">
<thead>
<tr>
<th data-options="field:'name'" width="220">Name</th>
<th data-options="field:'size'" width="100" align="right">Size</th>
<th data-options="field:'date'" width="150">Modified Date</th>
</tr>
</thead>
</table>


1) When I press button I get
Code:
syntax error ......  treegrid_data.json:1:1
This problem is visible in Firefox with basic.html from treegrid demo folder.

2) When I press button again (the New tab is already oppened) I get this:
Code:
TypeError: $.data(...) is undefined .......jquery.easyui.min.js:10107:7
« Last Edit: April 01, 2016, 04:05:23 AM by mzeddd » Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #1 on: April 03, 2016, 07:29:09 AM »

Please call 'refresh' method on a visible tab panel. Try this code instead.
Code:
$('#docTabs').tabs('select','New');
$('#docTabs').tabs('getTab','New').panel('refresh',address);
Logged
mzeddd
Full Member
***
Posts: 223



View Profile
« Reply #2 on: April 04, 2016, 01:45:05 AM »

It works.

What is the difference? Why it works like this?

What about syntax error?

Also I can see that load Ajax load is not working in Chrome when loading local file, not remote from web server. (see jquery-easyui-1.4.5/demo/tabs/nestedtabs.html example)

It seems like it is Chrome thing as it does not work in many examples.

Quote
XMLHttpRequest cannot load file://3pp/jquery-easyui-1.4.5/demo/treegrid/treegrid_data1.json. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.
« Last Edit: April 04, 2016, 01:50:25 AM by mzeddd » Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!