selectize.js icon indicating copy to clipboard operation
selectize.js copied to clipboard

Pass item selected object to onItemAdd

Open agborkowski opened this issue 12 years ago • 14 comments

Now:

/**
  value - selected value
  $item - selected option DOM
*/
onItemAdd(value, $item)

Expected:

/**
  value - selected value
  $item - selected option DOM
  item - selected object data with all data pass bt create/load 
*/
onItemAdd(value, $item, item)

Workaround: selectize.js, change line: -- self.trigger('item_add', value, $item); ++ self.trigger('item_add', value, $item, $option);

in your code by $option we can pass some extra data but access is complex eg.

 onItemAdd: function(value, item, option) {
                    var $cell = $($(this)[0].$wrapper).parent(), 
                        $addressInput = $cell.find('.address'),
                        $option = $(option),
                        $address = $option.find('.address');
//....

agborkowski avatar Jan 10 '14 16:01 agborkowski

+1

MaherSaif avatar Feb 10 '14 06:02 MaherSaif

+1

hotmeteor avatar Feb 10 '14 17:02 hotmeteor

+1

geordee avatar Apr 03 '14 05:04 geordee

+1

beeant avatar Oct 30 '14 01:10 beeant

+1

kobykorman avatar Jan 01 '15 14:01 kobykorman

+1

kevinmtrowbridge avatar Jan 27 '15 04:01 kevinmtrowbridge

+1

philostler avatar Feb 17 '15 10:02 philostler

+1

wimco avatar Feb 25 '15 18:02 wimco

+1

tharibo avatar Mar 06 '15 13:03 tharibo

+1

pjdewaele avatar Mar 18 '15 15:03 pjdewaele

+1

feugen24 avatar Mar 20 '15 13:03 feugen24

As far as I can tell all current options can be accessed through this.options, and so to get the selected option the following worked for me:

...
onItemAdd: function(value, $item) {
    console.log(this.options[value]);
},

leifdenby avatar Jun 24 '15 19:06 leifdenby

@leifdenby saved my day!

aksharj avatar Oct 06 '20 08:10 aksharj

closing stale issues older than one year. If this issue was closed in error please message the maintainers. All issues must include a proper title, description, and examples.

risadams avatar Dec 01 '20 13:12 risadams