javascript - select 2 add additional parameters to select options -
i need additional parameters <option></option>
tag generates select2 ajax data.
my ajax params select2(coffee):
ajax: url: '/moysklad_warehouse_items/find_warehouse_item' datatype: 'json' delay: 500 data: (query) -> { q: query.term } processresults: (data) -> { results: data }
resulted data structure:
[{id: 1, text: 'one', price: 100, weight: 10}, {id: w, text: 'two', price: 200, weight: 12}]
by default select2 provide id
, text
parameters , select looks this:
<select> <option value="10" selected="selected">one</option> <option value="11" selected="selected">one</option> </select>
i want add additional data(price , weight), like, parameters take part in calculations , text
tag if insufficiently
<option value="11" selected="selected" price="12" weight="100">one</option>
if impossible <option></option>
tag, normal if put, example, <span></span>
inside <option>
, add parameters <span>
if jquery option :
$('#optiontag').attr('my-awesome-attr','12'); //this if give option tag idea of 'optiontag'
Comments
Post a Comment