inputEx - DDListField Usage

Basic example

     
     var data = [
        {
          id: 'book_1',
          title: 'Book 1 title'
        },
        {
          id: 'book_2',
          title: 'Book 2 title'
        },
        {
          id: 'book_3',
          title: 'Book 3 title'
        },
        {
          id: 'book_4',
          title: 'Book 4 title'
        },
        {
          id: 'book_5',
          title: 'Book 5 title'
        }
      ];

      var container = Y.one('#container1');

      // Instantiate field
      var field = new Y.inputEx.DDListField({
        name: 'books', 
        valueKey: "id", 
        labelKey: "title", 
        parentEl: container,
        items: data
      });

      Y.Node.create("").appendTo(container).on( 'click', function() {
         alert( field.getValue().join(', ') );
      });
      
 

Add Item

     
     var data = [
        {
          id: 'book_1',
          title: 'Book 1 title'
        },
        {
          id: 'book_2',
          title: 'Book 2 title'
        }
      ];

      var container = Y.one('#container2');

      // Instantiate field
      var field = new Y.inputEx.DDListField({
        name: 'books', 
        valueKey: "id", 
        labelKey: "title", 
        parentEl: container,
        items: data
      });

      Y.Node.create("").appendTo(container).on( 'click', function() {
         field.addItem( {
            id: 'book_5',
            title: 'Book 5 title'
          });
      });
      
      
      Y.Node.create("").appendTo(container).on( 'click', function() {
         alert( field.getValue().join(', ') );
      });