EasyUI Forum
October 19, 2025, 02:45:23 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: How to define each TAB's ONCLOSE with different scenario?  (Read 9548 times)
Jonny
Newbie
*
Posts: 38


View Profile Email
« on: April 07, 2015, 01:33:45 AM »

Dear ALL,

Is there any syntax to ADD TAB with their own ONCLOSE behavior ( scenario ) ?
Everytime adding Tab, I create a temporary table in MySQL…
So… when closing TAB, I want to delete that temporary Table
This is my code:
function addTabxxx(title, url, tmptable ){
    if ($('#tablgn').tabs('exists', title))
            { $('#tablgn').tabs('select', title); }
   else {
            var vtemp = tmptable;
            var content = '<iframe scrolling="auto" frameborder="0"  src="'+url+'" style="width:100%;height:100%;">  </iframe>';
            $('#tablgn').tabs('add',{
                        title:title,
                        content: content,
                        bodyCls:'noscroll',
                        onClose: function(title,index){
                                    $.ajax({url : 'DLGN_KILLTMP.PHP',
                                                type : 'get',
                                                dataType : 'json',
                                                data : { temporary : vtemp },
                                                success : function(respond){ alert('Hello temporary table KILLED'); },
                                                error : function(a,b,c){alert('Error : '+b);}
                                                });       
                                                },
                          closable:true
                          });
            }
}         
This coding did not work… I don’t see any error in my parameter…
Maybe this syntax not acceptable….
If you know the correct Syntax.... Please guide me...
Thank you...

Regards,
JONNY
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: April 07, 2015, 01:58:32 AM »

When adding a tab panel, attach your 'tmptable' value to the panel options.
Code:
$('#tablgn').tabs('add',{
title:title,
closable:true,
tmptable:tmptable
})

When closing a tab panel, the 'onBeforeClose' event fires, you can retrieve the attached 'tmptable' value on this event and then make an ajax request to your remote server.
Code:
$('#tablgn').tabs({
onBeforeClose: function(title,index){
var p = $(this).tabs('getTab', index);
var tmptable = p.panel('options').tmptable;
}
})
Logged
Jonny
Newbie
*
Posts: 38


View Profile Email
« Reply #2 on: April 07, 2015, 02:28:44 AM »

Such a perfect solution for my case...
I never imagine easyui-tabs allow user to put any variable ('tmptable') when adding TAB....

I am spending a whole day seeking solution....... solved in a minute by you...
Thank you stworthy...

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!