0

How to pass a function to jquery ui tabs active option?

I can pass a function to jquery ui tabs activate option like this

activate: function(event, ui){
    localStorage.setItem("#" + $(this).context.id + "-current-index", $(this).tabs('option', 'active'));
}

How to get these value using active option, below code is not working

active: function(event, ui){
    localStorage.getItem("#" + $(this).context.id + "-current-index")
}

1 Answer 1

0

You may want to review the .getItem(). I would suggest the following:

function getData(i){
  return localStorage.getItem(i);
}

Then you can use it like so:

active: function(event, ui){
  ui.newPanel.html(getData("#" + $(this).context.id + "-current-index"));
}

Update

activate( event, ui ) Type: tabsactivate

Triggered after a tab has been activated (after animation completes). If the tabs were previously collapsed, ui.oldTab and ui.oldPanel will be empty jQuery objects. If the tabs are collapsing, ui.newTab and ui.newPanel will be empty jQuery objects.

See More: https://api.jqueryui.com/tabs/#event-activate

ui.newPanel is the jQuery Object that represents "the panel that was just activated." So we can then use .html() on that object.

.html( htmlString )

Description: Set the HTML contents of each element in the set of matched elements.

See More: https://api.jquery.com/html/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.