jQuery UI Widgets Forums Navigation Tabs Dynamic tags creation / selecting using ID attribute

This topic contains 1 reply, has 2 voices, and was last updated by  Hristo 9 years ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • Hi All,

    I hope this may be useful.

    Need for ID attribute came up while using jqxTabs along with jqxTree.

    To achieve is, up on clicking a node in Tree, it should create a Tab dynamically and put that at the last along with some content. If the node information already exists in the Tab it should select that Tab ( if available ). Also, at some time it may also required to set focus on the content ( having some other controls ) .

    we need to implement or change the jqxTabs.js

    //Implement new parameter agaID, that will take care of placing ID value for the tag
    addAtWithID: function(d, g, e, agaID) 
    {
    ...
    //var b = a("<li>" + g + "</li>");
    var b = a("<li id=" + agaID + " >" + g + "</li>");
    ...
    }
    //Implement new parameter agaID, that will take care of passing value for ID tag
    addLastWithID: function(c, b, agaID) {
                this.addAtWithID(this.length(), c, b, agaID)
            }
    
    //To create / select using ID attribute
    var tabId = 'tab_t1';
    
    //Find the Id is available.
    if ($(document).find("#" + tabId).length !== 0) {
         //ID exists in DOM
         // Find the all the available li tag in the DOM under jqxTabs , and find the index value of the ID 
         var myID = $('#jqxTabs').find("li").index($("#" + tabId));
         $('#jqxTabs').jqxTabs('select', myID);
    } else {
         //ID Does not exists in DOM
         $('#jqxTabs').jqxTabs('addLastWithID', t, 'Data: ' + t, tabId);
    }
    

    That it, it will be carried out well. it is working fine.

    May I know does this will create any problem, please advice or comment.

    Thanks,
    Damodharan.R


    Hristo
    Participant

    Hello Damodharan Rajaraman,

    We recommend to use documented options.
    Please take a look this demo:
    http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxtabs/settings.htm?light
    You could create “tabs” to a concrete position with addAt, addFirst (in the start) and addLast (in the end).
    If you need to check is there exist “tab” on particular index could use:
    var hasTab = !!$('#jqxTabs').jqxTabs('getTitleAt', index);

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.