jQWidgets Forums

jQuery UI Widgets Forums Navigation Menu, Context Menu jqxMenu – dynamicly change

This topic contains 4 replies, has 2 voices, and was last updated by  morfeusz 12 years, 1 month ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • jqxMenu – dynamicly change #15067

    morfeusz
    Participant

    Hello,
    I have menu:

    <div id='jqxMenu' >
    <ul>
    <li id='buttonMenu'>New...</li><
    <li>Search...
    <ul id='list_1'>
    <li>aaa</li>
    </ul>
    </li>
    </ul>
    </div>
    $('#jqxMenu').jqxMenu({theme: theme, width: '100%', height: '30px', showTopLevelArrows: true });

    Now I wont dynamicly change the items , so I do this:

    $('#list_1').html('');
    $('#list_1').append('<li>bbbb</li>');
    $('#jqxMenu').jqxMenu();

    And it’s not working.

    The source in jqxMenu don’t have many options, so I don’t use sources.

    jqxMenu – dynamicly change #15074

    Peter Stoev
    Keymaster

    Hi morfeusz,

    For dynamically adding Menu Items, check the Menu’s sample with Knockout.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    jqxMenu – dynamicly change #15078

    morfeusz
    Participant

    But how can I change onClick method?

    This is class to create items:

    var Person = function (name, items) {
    this.label = name;
    this.items = items != undefined ? ko.observableArray(items) : ko.observableArray();
    this.visible = ko.observable(true);
    this.addSubItem = function () {
    if (this.items().length < 1) {
    this.items.push(new Person("New Item"));
    }
    else if (this.items().length == 1) {
    this.items.push(new Person("Last Item"));
    this.visible(false);
    }
    }
    }

    Now I create new person (li in my example)

    new Person("B");

    But how to define ‘id’, ‘onclick’ or s’tyle’?

    jqxMenu – dynamicly change #15093

    Peter Stoev
    Keymaster

    Hi morfeusz,

    I suppose that you can add “id” field to the Person object for setting the “id”. Click events in jqxMenu are handled via the “itemclick” event.
    Here is an example which demonstrates how to handle the “itemclick” event: menubindingtojson.htm.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    jqxMenu – dynamicly change #15094

    morfeusz
    Participant

    Thanks for quick help.

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

You must be logged in to reply to this topic.