jquery-select2

django/ajax CSRF token missing

故事扮演 提交于 2019-12-31 07:08:10
问题 I have the following ajax function which is giving me a cross site forgery request token error once I get past the minimumlengthinput of 3 with the select2 control. Knowing this I attempted to add { csrfmiddlewaretoken: '{{ csrf_token }}' }, to my data:. After adding the csrfmiddlewaretoken I'm still getting the CSRF token missing or incorrect error. I believe it has something to do with the my function for the searchFilter and searchPage follows. What is the proper way to do this? // using

jQuery select2: duplicate tag getting recreated

瘦欲@ 提交于 2019-12-31 05:20:09
问题 I asked a question earlier today (jquery select2: error in getting data from php-mysql). However, I am trying to fix it and doing that now I am getting bit strange issue. I am not sure why it is happening like this. Below is the JavaScript code. <div class="form-group"> <label class="col-sm-4 control-label">Product Name</label> <div class="col-sm-6"> <input type="hidden" id="tags" style="width: 300px"/> </div> </div> <script type="text/javascript"> var lastResults = []; $("#tags").select2({

Add options to Select2 after inititialzation

…衆ロ難τιáo~ 提交于 2019-12-30 08:18:08
问题 This seems like a standard thing to want to do, but I'm struggling to find a clear and simple solution. I want to be able to add one or more additional options to an already initialized Select2. I am using an older version of Select2, not sure what the version is off hand though. 回答1: You can solve most questions involving Select2 in the same way that they would be solved in a standard <select> . In this case, the corresponding <select> question would be: Adding options to select with

Load values in select2 multiselect

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-30 06:26:13
问题 I'm using select2 in place of search box. Here i'm using to load countries values like this $("#countries").select2({ multiple: true, tags:["India", "Japan", "Australia","Singapore"], tokenSeparators: [","] }); When i press save button, they are properly submitted to the server, now here the question is when i want to modify the country field after saving to server, how i can load the saved values to the country field. This is how i retrieve data from server $.getJSON('/dataprovider?data

Load values in select2 multiselect

亡梦爱人 提交于 2019-12-30 06:26:07
问题 I'm using select2 in place of search box. Here i'm using to load countries values like this $("#countries").select2({ multiple: true, tags:["India", "Japan", "Australia","Singapore"], tokenSeparators: [","] }); When i press save button, they are properly submitted to the server, now here the question is when i want to modify the country field after saving to server, how i can load the saved values to the country field. This is how i retrieve data from server $.getJSON('/dataprovider?data

Get attributes values from select2 selected option

六眼飞鱼酱① 提交于 2019-12-30 03:27:06
问题 I'm using the Select2 plugin from http://ivaynberg.github.io/select2/select2-latest.html what works fine but i'm having a problem to get the values from the options attributes. I've got a select menu like this: <select name="invoice_line[0][vat]" class="vat"> <option value="20440" data-value="21.00" data-name="20440" selected="selected">21%</option> <option value="20441" data-value="6.00" data-name="20441">6%</option> <option value="20442" data-value="0.00" data-name="20442">0%</option> <

How to implement sublime text like fuzzy search?

旧巷老猫 提交于 2019-12-29 18:38:12
问题 How can i implement a sublime-like fuzzy search on select2? Example, typing "sta jav sub" would match "Stackoverflow javascript sublime like" 回答1: Here's an alternate matching function. http://jsfiddle.net/trevordixon/pXzj3/4/ function match(search, text) { search = search.toUpperCase(); text = text.toUpperCase(); var j = -1; // remembers position of last found character // consider each search character one at a time for (var i = 0; i < search.length; i++) { var l = search[i]; if (l == ' ')

select2 - Setting different width to input and dropdown

心不动则不痛 提交于 2019-12-29 18:18:51
问题 I am using Select2 3.3.2 I have very very long options in the select. Example: <select id="e1"> <option value="AL">Alabama</option> <option value="WY">Wyoming</option> <option value="WY">very long long long text</option> <option value="WY">very long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long

select2 - Setting different width to input and dropdown

感情迁移 提交于 2019-12-29 18:17:11
问题 I am using Select2 3.3.2 I have very very long options in the select. Example: <select id="e1"> <option value="AL">Alabama</option> <option value="WY">Wyoming</option> <option value="WY">very long long long text</option> <option value="WY">very long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long

What are the differences between Chosen and Select2?

风流意气都作罢 提交于 2019-12-29 02:20:09
问题 Chosen and Select2 are the two more popular libraries for extending selectboxes. Both seem to be actively maintained, Chosen is older and supports both jQuery and Prototype. Select2 is jQuery only, its documentation says Select2 is inspired by Chosen, but doesn't detail any improvements made (if any) or other reasons for the rewrite. Two libraries have pretty much same feature set, the only comparison I've found is a somewhat inconclusive jsperf test page. Does any of these libraries have any