EasyUI Forum
May 14, 2024, 11:51:03 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: Dynamic Icons on Tabs  (Read 6712 times)
stollar
Newbie
*
Posts: 7


View Profile Email
« on: October 31, 2015, 03:09:42 AM »

I want to programatically add an icon to a tab - the tab contains data which needs saving and once the data is dirty I want to place a SAVE icon on the tab.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: October 31, 2015, 05:23:42 AM »

Please call 'update' method to update a tab panel. The code below shows how to update the icon on a selected tab panel.
Code:
var t = $('#tt');
var p = t.tabs('getSelected');
t.tabs('update', {
  tab: p,
  type: 'header',
  options: {
    iconCls: 'icon-ok'
  }
})
Logged
stollar
Newbie
*
Posts: 7


View Profile Email
« Reply #2 on: November 01, 2015, 02:42:48 AM »

Can I add an event handler to the icon at the same time? Something like:   (this didn't work out)
Code:
var t = $('#tt');
var p = t.tabs('getSelected');
t.tabs('update', {
    tab: p,
    type: 'all',
    options: {
        iconCls: 'icon-save',
        handler:function() {
            console.log('SAVE');
        }
    }
});
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 on: November 01, 2015, 03:13:51 AM »

No, you can not do that. Please set the 'tools' instead.
Code:
var t = $('#tt');
var p = t.tabs('getSelected');
t.tabs('update', {
  tab: p,
  type: 'header',
  options: {
    iconCls: 'icon-ok',
    tools:[{
      iconCls:'icon-mini-refresh',
      handler: function(){
        alert('refresh')
      }
    }]
  }
})
Logged
stollar
Newbie
*
Posts: 7


View Profile Email
« Reply #4 on: November 02, 2015, 08:13:20 AM »

This worked really well and when data in the tab changes I can add the SAVE icon which fires the function when clicked. But, here's my problem:  I need to know the TAB number which holds the pressed icon.  Bearing in mind that it quite possibly won't be the SELECTED tab.  How can I get the Tab number inside the function?  I also need to keep in mind that some tabs may have been closed which may mess with any saved values.

Any suggestions?

Code:
var t = $('#tt');
var p = t.tabs('getSelected');
t.tabs('update', {
  tab: p,
  type: 'header',
  options: {
    iconCls: 'icon-ok',
    tools:[{
      iconCls:'icon-mini-refresh',
      handler: function(){
        alert('SAVE TAB #'+tabNo);
      }
    }]
  }
})
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!