javascript - Selectize.js custom rendering with static html -
I am using the great selectize.js library to create an attractive selection box with option groups. It's all working, but I am stuck in the fact that I can not use a custom renderer from the example page (email contact) because "item" is not aware of the "email" attribute I know how to do it in javascript Is, but how can I define two attributes in static HTML?
In JS, this wish
$ ('# id'). Select ({... option: [{name: "Martin", email: "martin@asdf.at"}], ....} I tried the following :
& lt; select & gt; option value = "Martin Martin @ ASDF.At" data-name = "Martin" data-email = "Martin @ ASDF .ttt; Martin & lt; / option & gt; & lt; / select & gt; but this is not working ... finally taken from the examples Function:
Render: {item: function (item, escape) {return '& lt; div & gt;' + (item.name? '& Lt; span class = "name" & gt; '+ escape (item.n Ame) + '& lt; / span & gt;': '') ('items mail?' "+ escape (item.email) + '& lt; / Span & gt; ':' ') +' & lt; / div & gt; ';}, option: function (item, escape) {var label = item.name} item.email; var caption = item.name? Item.email: null; return '& lt; div & gt;' + '& lt; span class = "label" & gt;' + escape (label) + '& lt; / span & gt;' + (caption ? '& Lt; span class = "caption" & gt;' + escape (caption) + '& lt; / Span & gt; ' : '') + '& Lt; / Div & gt; '; }} I would be grateful for any indication!
Regards, Martin
Use this example: < Pre> var clearhack = $ ('selected'). Select ({valueField: 'id', labelField: 'name', SearchField: ['name'], sort field: 'score', // This is set to 'name' on my version, but it seems that the use of sortfield Only load function and score-function is done with sorting of the order: 'desc', maxItems: 1, // using the option-value only in jsfiddle - the real world is using the load-function option: [ {"Id": 111, "name": "jenny", "score": 6}, {"id": 394, "id": 861, "name": "jennifer", "score": 6}, {"id": 111, "Name": "George", "Score": 6}, {"id": 1065, " {"Id": 859, "name": "Jorge Carlson", "Score": 6}, {"id": 389, "name": "n jennifer", "score" "," "Name": "Peter Jenkins", "score": 3}, {"id": 990, "name": "Fred", "Bobby Jenkins", "numerals": 3}, {"id": 264, Score ": 1}, {" id ": 349," name ":" tomorrow "," score ": 1}, {" id ": 409," name ":" Louis "," score ": 1}] , Create: wrong, render: {option: function (item, escap e) {return '& lt; div & gt;' + '& lt; span & gt; id:' + item.id + '& lt; / span & gt; '+' & lt; span & gt; name: '+ item.name +' & lt; / span & gt; '+' & lt; Span & gt; DEBUG: '+ item.score +' & lt; / Span & gt; '+' & Lt; / Div & gt; '; }}, Score: function (search) {return function (item) {return parasont (item saokor); }; }});
Comments
Post a Comment