EasyUI Forum
May 08, 2024, 09:24:32 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: js functions dynamic tabs  (Read 17206 times)
baxter
Newbie
*
Posts: 32


View Profile Email
« on: May 17, 2012, 02:16:34 AM »

Hello,

i will write a portal with dynamic tabs. for this a add follow function:

Code:
// add a new tab panel
var index = 0;
function addTab(url, title){
   
    index++;
    var plaincontent=getContent("/window.php"+url);

    $('#tt').tabs('add',{
title: title,
href: "/window.php"+url,
iconCls:'icon-save',
closable:true,
tools:[{
    iconCls:'icon-mini-refresh',
    handler:function(){
alert('refresh');
    }
}]
    });
}

the problem is all javascript functions inside the load site "/window.php"+url" dosnt working and i dont know why. The jeasyui functions inside the loaded content doesnt work too.

I have try to load a content with  (and the <script src...> tags and without html header. Same result, functions not work.

Any idea?

Thanks
baxter
Logged
Kevin
Jr. Member
**
Posts: 52


View Profile Email
« Reply #1 on: May 17, 2012, 07:01:02 AM »

Hi Baxter, welcome to the community. I'm doing pretty must the same as what your code does without any issues. Make sure title and url have valid data. Also, check the way you are referencing your call to the PHP file. Try removing the / from you href. ie href: "window.php"+url,

I would also try this to make sure your basic logic is working. Just create a file with the following line;
Hello World!

Save it as 'hello.php' in the root folder of you web site.

Change your call to create the tab to;
               $('#tt').tabs('add', {
                  title: 'My Title',
                  href: 'hello.php',
                  closable: true
               });
Test it to make sure it is working and then add the features you required before. When it breaks, you will know what is causing this.
Logged
baxter
Newbie
*
Posts: 32


View Profile Email
« Reply #2 on: May 17, 2012, 07:52:27 AM »

Hey Kevin,

thanks for your replay. No, thats ist not a problem. The "/window.php"+url, request loading correct. its only the js and jeasyui tags code inside the html that not work.
As example i've a datagrid block inside the code and the datagrid is not view and loading.
Logged
Kevin
Jr. Member
**
Posts: 52


View Profile Email
« Reply #3 on: May 17, 2012, 03:53:26 PM »

Sorry about that. I should read a little slower. Ok, try this and then modify it for your code.
Create a file and call it test.php. Add this code to it;
Code:
<!DOCTYPE html>
<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <title>Demo</title>
      <link class="jeasycss" rel="stylesheet" type="text/css" href="http://www.jeasyui.com/easyui/themes/default/easyui.css" />

      <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
      <script type="text/javascript" src="http://www.jeasyui.com/easyui/jquery.easyui.min.js"></script>
      <script type="text/javascript">
         function openTab() {
            $('#tt').tabs('add', {
               title: 'New Tab',
               href: 'tab.php',
               closable: true
            });
         }
      </script>
   </head>
   <body class="easyui-layout" style="text-align:left">
      <div region="west" border="false" split="true" title="Topics" style="width:250px;padding:5px;">
         <ul class="easyui-tree">
            <li><span>Login</span>
               <ul>
                  <li><a href="#" onclick="openTab()">Topic 1</a></li>
                  <li><a href="#" onclick="openTab()">Topic 2</a></li>
               </ul>
            </li>
         </ul>
      </div>
      <div region="center" border="false">
         <div id="tt" class="easyui-tabs" fit="true" border="false" plain="true">
         </div>
      </div>
   </body>
</html>

Then create another file and call that tab.php. Add this code to it;
Code:
<table id="tt"></table>
<script type="text/javascript">
   function sayHello() {
      $.messager.alert('Message', 'Hello');
   }
</script>
<table id="tt" class="easyui-datagrid" style="width:700px;height:250px"
   title="Load Data" iconCls="icon-save"
   rownumbers="true" pagination="true">
   <thead>
      <tr>
         <th field="itemid" width="80">Item ID</th>
         <th field="productid" width="120">Product ID</th>
         <th field="listprice" width="80" align="right">List Price</th>
         <th field="unitcost" width="80" align="right">Unit Cost</th>
         <th field="attr1" width="200">Attribute</th>
         <th field="status" width="60" align="center">Stauts</th>
      </tr>
   </thead>
</table>
<button onclick="sayHello()">Say Hello</button>

Whenever you click on an item in the tree, it will open a tab and display a working jeasyui datagrid in the tab. There is also a button to run some simple JavaScript which calls a jeasyui function. I'm not sure what you are doing in your php code, but I hope this helps.
« Last Edit: May 17, 2012, 03:58:09 PM by Kevin » Logged
baxter
Newbie
*
Posts: 32


View Profile Email
« Reply #4 on: May 21, 2012, 03:17:05 PM »

oh, i had forget the answer...

Thanks again... ist work. I must load the js files with functions in the tab window then works.
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!