EasyUI Forum
May 05, 2024, 12:55:35 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: Cancelling a tab selection  (Read 4011 times)
sectioni
Jr. Member
**
Posts: 67


View Profile
« on: April 09, 2017, 06:51:43 AM »

Hello,

I would like to do a 'confirm' dialog when switching tabs and only if OK i pressed, then the new tab should be selected and the 'onSelect' and 'onUnselect' events will be triggers.

I have not found a way of doing that...
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: April 10, 2017, 08:02:18 AM »

Please attach the 'onBeforeOpen' event handler to each tab panels.
Code:
<script>
function onBeforeOpen(){
var opts = $(this).panel('options');
if (opts.canOpen == undefined){
opts.canOpen = false;
}
if (opts.canOpen){
return true;
}
$.messager.confirm('Confirm','Are you sure to select '+opts.title+'?', function(r){
if (r){
opts.canOpen = true;
$('#tt').tabs('select',opts.index);
opts.canOpen = false;
}
});
return false;
}
</script>
<div id="tt" class="easyui-tabs" style="width:700px;height:250px">
<div title="tab1" data-options="onBeforeOpen:onBeforeOpen"></div>
<div title="tab2" data-options="onBeforeOpen:onBeforeOpen"></div>
</div>
Logged
sectioni
Jr. Member
**
Posts: 67


View Profile
« Reply #2 on: April 12, 2017, 03:45:49 AM »

Works perfectly.
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!