Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8709129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:17:40+00:00 2026-06-13T04:17:40+00:00

I am trying to use Knockout in the following scenario: I have jquery UI

  • 0

I am trying to use Knockout in the following scenario:
I have jquery UI tabs and Next / Prev buttons. I would like the buttons to disappear according the to selected tab – the Next will be hidden in the last tab and the Prev will be hidden in the first tab. Here is what I’ve done:

//HTML
<div id="buttonsDiv">
    <button id="prevButton" data-bind="visible: prevVisible">Prev</button>
    <button id="nextButton" data-bind="visible: nextVisible">Next</button>
</div>

//JavaScript
function TabsButtons = function (tabsSize) {
    //Computed
    this.selectedTab = ko.computed(0);

    this.nextVisible = ko.computed(function () {
        return this.selectedTab() < tabsSize - 1;
    }, this);

    this.prevVisible = ko.computed(function () {
        return this.selectedTab() > 0;
    }, this);
};

        var $tabs = this.tabs({
            select: function (event, ui) {
                tabsButtonsModel.selectedTab(ui.index);
            }
        });

var tabsButtonsModel = new TabsButtons($tabs.find('.ui-tabs-panel').size());
ko.applyBindings(tabsButtonsModel, $('#buttonsDiv').get(0));

I would like to remove the ‘select’ event of the tabs plugin and use Knockout in a way that the selectedTab property will updated automatically.
Is that possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T04:17:41+00:00Added an answer on June 13, 2026 at 4:17 am

    What I have done is similar to your answer but less code. Instead of adding click event on each tab, I just move the event into the model. I created a generic model that gets the tabs element and creates a model for it:
    function TabsPrevNextButtonsModel (tabs) {
    this.selectedTab = ko.observable(tabs.tabs(‘option’, ‘selected’));

        var tabsSize = tabs.find('.ui-tabs-panel').size();
        tabs.bind('tabsselect', $.proxy(function (event, ui) {
            this.selectedTab(ui.index);
        }, this));
    
        this.next = function (data, event) {
            tabs.tabs('option', 'selected', (this.selectedTab() + 1) % tabsSize);
        }
        this.prev = function (data, event) {
            tabs.tabs('option', 'selected', (this.selectedTab() - 1) % tabsSize);
        }
    
        //Computed
        this.nextVisible = ko.computed(function () {
            return this.selectedTab() < tabsSize - 1;
        }, this);
    
        this.prevVisible = ko.computed(function () {
            return this.selectedTab() > 0;
        }, this);
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Problem: I am trying to use knockout.js with jquery templates. The problem is that
I'm trying use jquery ui tabs together with js and mvc3. <div class=demo> <div
I am trying use gem tire to search in my application. I have tables
I'm trying use mod_rewrite to rewrite URLs from the following: http://www.site.com/one-two-file.php to http://www.site.com/one/two/file.php The
Hi I'm trying use a datepicker on a field I have. I'm trying to
I am need paint my image. I'm trying use JQuery in here this link:
trying to use hibernate with my web app and getting following exception: Initial SessionFactory
Trying to use the new cleaner event handling in Knockout 2 along with the
I am trying to use knockout.validation plugin. I want created a custom validation rule
I am trying to use knockout.validation plugin. I created an exampleViewModel : function exampleViewModel()

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.