EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: quilluser on September 08, 2013, 02:55:57 AM



Title: datebox only working once
Post by: quilluser on September 08, 2013, 02:55:57 AM
This is driving me mad as I can't work out what I'm doing wrong. I have a PHP page which is loaded into a layout region and contains a datebox. All is fine when the page is loaded, using a menu, for the first time. Subsequent loading of the page displays the datebox correctly but is is inactive, no calendar will appear. While I'm including the necessary js files in the main index page I find I have to also include them in the loaded page or the datebox won't work in the loaded page at all. Is this what's causing it and can I get around it? Your help will be most appreciated. BTW, I have other similar setups which are working perfectly  ???


Title: Re: datebox only working once
Post by: quilluser on September 08, 2013, 04:13:06 AM
As an addition to this, the error console shows the following:
Whenever a page with a datebox is displayed : TypeError: 'undefined' is not an object (evaluating 'a.nodeName')
When the datebox is clicked after the first time: TypeError: 'undefined' is not an object (evaluating '$.data(_1c4,"panel").options')


Title: Re: datebox only working once
Post by: stworthy on September 08, 2013, 06:53:10 AM
Please provide an example to demonstrate your issue.


Title: Re: datebox only working once
Post by: quilluser on September 08, 2013, 10:49:37 AM
Hi, thanks for the response. I've prepared two files as coded below. Thanks for your help. I'm assuming that you have the standard css and js file required. Steve

example.php

Code:
<?PHP
session_start();
?>
<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Example</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="css/field.css">
    <script type="text/javascript" src="js/jquery-1.8.0.min.js"></script>
    <script type="text/javascript" src="js/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="js/jquery.parser.js"></script>
  </head>
<body class="easyui-layout" style="font-family:Arial,Helvetica,sans-serif;">
<div id="top" data-options="region:'north',split:true">
<p>EXAMPLE</p>
</div>
<div data-options="region:'south',split:true" style="height:30px;background:#efefef;">
  <div id="msg" style="padding-left:10px;">
    Not logged in 
  </div>
</div>
<div data-options="region:'west',split:true" title="Menu Options" style="width:200px;padding1:1px;overflow:hidden;">
<div data-options="fit:true,border:false">
  <div title="Transactions" data-options="selected:true" style="padding:10px;overflow:auto;">
  <ul style="list-type:none;padding:0;margin:0;">
    <li onclick="$('#content').load('test.php');">Load form</li>
    <li onclick="$('#content').html('Page loads here');">Clear</li>
  </ul>
  </div>
</div>
</div>
<div data-options="region:'center'" title="Work and result zone" style="overflow:hidden;">
  <div id="content" style="padding:10px;">
    Page loads here
  </div>
</div>
</body>
</html>

test.php

Code:
<?PHP
session_start();
?>
<input type="text" class="easyui-datebox" id="t" />
<script type="text/javascript" src="js/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="js/jquery.easyui.min.js"></script>

<script type="text/javascript">
$.fn.datebox.defaults.formatter = function(date){
var y = date.getFullYear();
var m = date.getMonth()+1;
if(m<10){m='0'+m;}
var d = date.getDate();
if(d<10){d='0'+d;}
return d+'/'+m+'/'+y;
}
</script>


Title: Re: datebox only working once
Post by: stworthy on September 08, 2013, 05:27:16 PM
Please redefine your center panel as:
Code:
	<div data-options="region:'center'" title="Work and result zone" style="overflow:hidden;">
  <div id="content" class="easyui-panel" style="padding:10px;">
    Page loads here
  </div>
</div>

The loading script should be:
Code:
$('#content').panel('refresh', 'test.php');


Title: Re: datebox only working once
Post by: quilluser on September 10, 2013, 03:36:38 PM
Sorry for the delay, I've been away for a day or two. Many thanks for your suggestion which, unfortunately, didn't work. The panel loaded with two dateboxes instead of one and neither was "active".


Title: Re: datebox only working once
Post by: stworthy on September 10, 2013, 07:04:40 PM
Be sure to remove <script> tags from test.php file.


Title: Re: datebox only working once
Post by: quilluser on September 11, 2013, 03:09:29 AM
Brilliant! That did it. Many thanks for your interest in this one.