EasyUI Forum
April 29, 2024, 06:16:01 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: accordion behaved weirdly  (Read 5659 times)
Lioncat
Newbie
*
Posts: 4


View Profile Email
« on: April 04, 2016, 07:02:03 AM »

I try to combine accordion basic and tree AJAX load examples into one, something weird happened. Attached the code below, now it works. Pay attention to those comment out sentence, when I  use "var pp = acdn.accordion('getSelected')" in place of "$('#acdn').accordion('getSelected')" it stop to work, till you comment in other 2 sentences in place of the same functional sentences. I use easyui 1.4.5.
Code:
<html>
<head>
<meta charset="UTF-8">
<title>Basic Accordion - jQuery EasyUI Demo</title>
<link rel="stylesheet" type="text/css" href="../../themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="../../themes/icon.css">
<link rel="stylesheet" type="text/css" href="../demo.css">
<script type="text/javascript" src="../../jquery.min.js"></script>
<script type="text/javascript" src="../../jquery.easyui.min.js"></script>
<script type="text/javascript" src="json2TreeLoadFilter.js"></script>
<script>
var acdn, count = 0, sig = 0;

function onSel(ttl, idx) {
count++;
// var pp = acdn.accordion('getSelected');
var pp = $('#acdn').accordion('getSelected');
if (ttl === "TreeMenu") {
if (!sig) {
pp.html('<ul class="easyui-tree" data-options=' + '"url:' + '\'tree_data1.json\',method:\'get\',loadFilter:json2TreeLoadFilter' + '"' + '></ul>');
$.parser.parse(pp);;
sig = 1;
}
$('#info').text(pp.text());
} else if (ttl === "Help" && count > 2) {
pp.html("<h2>Hello, I'm here to mess up!</h2>");
}
};

function onClick() {
alert('hello!');
}

$(function() {
acdn = $('#acdn');
// acdn.accordion({ onSelect: onSel });
});
</script>
</head>

<body>
<h2>Basic Accordion</h2>
<p>Click on panel header to show its content. <span id="info"></span></p>
<div style="margin:20px 0 10px 0;"></div>
<div id="acdn" class="easyui-accordion" style="width:500px;height:300px;" data-options="onSelect:onSel, selected:-1">
<!-- <div id="acdn" class="easyui-accordion" style="width:500px;height:300px;">-->
<div title="About" data-options="iconCls:'icon-ok'" style="overflow:auto;padding:10px;">
<h3 style="color:#0099FF;">Accordion for jQuery</h3>
<p>Accordion is a part of easyui framework for jQuery. It lets you define your accordion component on web page more easily.</p>
</div>
<div title="TreeMenu" data-options="iconCls:'icon-search'" style="padding:10px;">
</div>
<div title="Nothing" data-options="iconCls:'icon-cancel', collapsible:false" style="padding:10px;" onclick="onClick()">
</div>
<div title="Accordion" data-options="iconCls:'icon-add'" style="padding:10px;">
<h3 style="color:#0099FF;">Accordion from jQuery EasyUI</h3>
<p>Accordion is a part of easyui framework for jQuery. It lets you define your accordion component on web page more easily.</p>
</div>
<div title="Help" data-options="iconCls:'icon-help'" style="padding:10px;">
<p>The accordion allows you to provide multiple panels and display one or more at a time. Each panel has built-in support for expanding and collapsing. Clicking on a panel header to expand or collapse that panel body. The panel content can be loaded via ajax by specifying a 'href' property. Users can define a panel to be selected. If it is not specified, then the first panel is taken by default.</p>
</div>
</div>
</body>
</html>
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!