jQuery-EasyTabs icon indicating copy to clipboard operation
jQuery-EasyTabs copied to clipboard

is it possible to update the tab set?

Open CBox opened this issue 11 years ago • 17 comments

I've needed to update the tab set after i added more tab container and link, so Iv'e got this error: Uncaught Error: Tab '#story-15' does not exist in tab set

and the tab container exist and the link, but i need to find a way to update the tab set on live.

is it possibble?

CBox avatar Feb 26 '13 18:02 CBox

There's not currently a way to manually add a tab to the set, but you could grab the attached easytabs object and re-run init(), like this:

$('#tab-container').easytabs();

// do some stuff, add a new tab.

$('#tab-container').data('easytabs').init();

JangoSteve avatar Feb 26 '13 18:02 JangoSteve

Iv'e try this and i'm getting this error: Uncaught Error: Syntax error, unrecognized expression: #/

i'm using this like this: if(jQuery().easytabs) { $('#ajax-tabs').easytabs({ animationSpeed: "fast", transitionIn: "fadeIn", updateHash : false }); }

/// so some things....

$('#ajax-tabs').data('easytabs').init();

any idea?

thanks.

CBox avatar Feb 26 '13 19:02 CBox

That's not really enough to go on. Where's the error coming from?

JangoSteve avatar Feb 26 '13 19:02 JangoSteve

from the jquery-1.7.1.min.js:1

i just wrap this in: $('#submit').live('click', function() { $('#ajax-tabs').data('easytabs').init(); });

and i'm getting this error...

( I've change my profile, CBox it's still me :+1: )

EFRI avatar Feb 26 '13 19:02 EFRI

Oh, that sounds like it might actually be an issue I encountered myself and fixed a few weeks ago. Apparently I forgot to push the fix to Github. Try using the latest easytabs from this repo now. Here is the commit I pushed: https://github.com/JangoSteve/jQuery-EasyTabs/commit/17ee0f3c106c919b3c5d68e4466140024b76594e

JangoSteve avatar Feb 26 '13 19:02 JangoSteve

it's working great now! but unfortunately it's active 2 tabs when i add more tab. thank you for your support!

EFRI avatar Feb 26 '13 20:02 EFRI

I'm just guessing now, since I haven't personally tried doing this, but maybe try something like this:

var $tabContainer = $('#tab-container');
$tabContainer.easytabs();

// do some stuff, add a new tab.

var myeasytabs = $tabContainer.data('easytabs');
myeasytabs.tabs.removeClass(myeasytabs.settings.tabActiveClass);
myeasytabs.panels.removeClass(myeasytabs.settings.panelActiveClass);
myeasytabs.init();

JangoSteve avatar Feb 26 '13 20:02 JangoSteve

i don't know how to thank you! it's working great! thanks alot for your support and patient.

CBox avatar Feb 26 '13 20:02 CBox

No prob. It'd probably be a good idea for me to do some refactoring and pull the addTab() function out to a public method you could call without having to re-init easytabs.

JangoSteve avatar Feb 26 '13 20:02 JangoSteve

i don't know what change but after the second time that i'm adding a tab i;m getting this erorr: Uncaught TypeError: Cannot read property 'tabActiveClass' of undefined $.ajax.success l jquery-1.7.1.min.js:1 c.fireWith jquery-1.7.1.min.js:1 r jquery-1.7.1.min.js:1 r

CBox avatar Feb 28 '13 14:02 CBox

I've chacked and after the myeasytabs.init(); some how it's delete the object. any idea?

CBox avatar Feb 28 '13 15:02 CBox

Hey @CBox, sorry for the confusion. Each time you call myeasytabs.init(), it's deleting and re-creating the easytabs data object on the tab container element, which means simply that your myeasytabs variable is getting de-referenced. You can fix this by re-setting your myeasytabs var after you call init():

myeasytabs.init()
myeasytabs = $tabContainer.data('easytabs');

It's not ideal, but I plan to make it easier to add tabs in a future version anyway. Another thing I should probably think about would be to have the init() function return the data object, so you could also do something like myeasytabs = myeasytabs.init() to combine the above two lines.

I'll reopen this issue as a reminder to myself to look into these features.

JangoSteve avatar May 09 '13 05:05 JangoSteve

Hello! I have a same problem, but your temporary solution doesn't work for me.

$(container_id).easytabs({
  defaultTab: $(container_id+' ul.dynatable-tabs > li:eq(0) > a').parent(),
  tabs: $(container_id+' ul.dynatable-tabs > li > a').parent(),
  panelClass: 'tabs-hide',
  updateHash: false,
  animate: true,
  animationSpeed: 'fast',
  transitionIn: 'slideDown',
  transitionOut: 'slideUp'
});

Tabs set don't updated after myeasytabs.init(). Maybe it happens because I set 'tabs' variable? Can you help please?

Craigy- avatar May 31 '13 14:05 Craigy-

Hello,

Any ETA on new features (Add, Delete and re-order etc.)?

We had to do many things manually and this tabs is excellent with history option. Starting new project and POC and really want to know the ETA.

bobmehta avatar Jul 03 '13 14:07 bobmehta

Public method is no more working after myeasytabs.init(); call.

var $tabContainer = $('#tab-container');
$tabContainer.easytabs();

// do some stuff, add a new tab.

var myeasytabs = $tabContainer.data('easytabs');
myeasytabs.tabs.removeClass(myeasytabs.settings.tabActiveClass);
myeasytabs.panels.removeClass(myeasytabs.settings.panelActiveClass);

myeasytabs.init();
myeasytabs = $tabContainer.data('easytabs');

$tabContainer.easytabs('select', '#tab-3');  // It does not select.

How can it be fixed?

hopecee avatar Oct 21 '15 19:10 hopecee

I have figured out something. $tabContainer.data('easytabs') object is empty after calling myeasytabs.init(). It needs to be reassigned with myeasytabsvalue.

var $tabContainer = $('#tab-container');
$tabContainer.easytabs();

// do some stuff, add a new tab.

var myeasytabs = $tabContainer.data('easytabs');
myeasytabs.tabs.removeClass(myeasytabs.settings.tabActiveClass);
myeasytabs.panels.removeClass(myeasytabs.settings.panelActiveClass);
myeasytabs.getTabs();     // use this method to touch/get all the tabs.

myeasytabs.init();   

myeasytabs.publicMethods.select('#tab-3'); //use this method to select tab.

// $tabContainer.data('easytabs');  is empty here and needs to be reassigned.
$tabContainer.data('easytabs', myeasytabs);

$tabContainer.easytabs('select', '#tab-2'); //this method will start working now.


// do some stuff, add another new tab.


myeasytabs = $tabContainer.data('easytabs');
myeasytabs.tabs.removeClass(myeasytabs.settings.tabActiveClass);
myeasytabs.panels.removeClass(myeasytabs.settings.panelActiveClass);
myeasytabs.getTabs();     // use this method to touch/get all the tabs.

myeasytabs.init(); 

I still need to figure out why it is hiding other scripts from executing.. I need your comments Steve.

hopecee avatar Oct 23 '15 10:10 hopecee

It seems that calling myeasytabs.init() disbound any function that is bound to any html element inside the tabContainer. For it to continue working, you have to rebind it. e.g.

function test() {
$('.tabContainer-innerElement').on('click', function() {
alert('test');
}


test();
...
myeasytabs.init();  
...
//test() stops executing unless you call it again.
test();

hopecee avatar Oct 23 '15 14:10 hopecee