selectize.js

TypeError: $(…).selectize is not a function

做~自己de王妃 提交于 2019-12-05 06:00:33
I installed the "selectize-rails" gem into my rails app, and I'm trying to get it to work. I keep getting this error in my web console: TypeError: $(...).selectize is not a function and nothing happens in the browser. Here's the code I have so far, following the "Email Contacts" example from this page: http://brianreavis.github.io/selectize.js/ views/emails/new.html.erb <script type="text/javascript"> $(document).ready(function() { console.log( typeof $.fn.selectize === 'function'); // true console.log( $('#select-to').length === 1 ); // true var REGEX_EMAIL = '([a-z0-9!#$%&\'*+/=?^_`{|}~-]+(?

Selectize dropdown width independent of input

心不动则不痛 提交于 2019-12-05 03:57:33
I am trying to use Selectize to render a dropdown of very long labels. The text can be pretty wide, but the input has a constraint on width. Selectize perfectly wraps the text (in both the input and drop downs) but ideally the drop down would be able to scale wider than the input to allow better readability. Is it possible to get Selectize to have a dropdown width independent of the input? <select style="width:300px" multiple> <option value="">Enter some tags...</option> <option value="1" selected>QID7_4 : Where do you store your digital photos? Check all that apply.-On a cloud service like

Capybara integration tests with jquery.selectize

坚强是说给别人听的谎言 提交于 2019-12-04 03:12:13
问题 How can I write a capybara integration test with a form using jquery.selectize? I'd like to test a user entering a couple of values. 回答1: I created a helper that I mix in to my capybara feature specs: module PageSteps def fill_in_selectized(key, *values) values.flatten.each do |value| page.execute_script(%{ $('.#{key} .selectize-input input').val('#{value}'); $('##{key}').selectize()[0].selectize.createItem(); }) end end end And here's an example of how it is used: # Single value fill_in

Get Text From Selected using selectize

岁酱吖の 提交于 2019-12-04 02:44:48
I've tried this: var eventHandler = function() { return function() { console.log($select.val()); }; }; var $select = $('.selectize').selectize({ create : true, onChange : eventHandler() }); Which get me the value of the selected option but I need the text. When I do this: console.log($select.val().text()); I get an error. I've tried other things to no avail. How do I get the selected text? select_option.getItem(select_option.getValue())[0].innerHTML; select_option = $select_option[0].selectize; to get text value of a specified dropdown option. this.getItem(value)[0].innerHTML to get text value

How to clear a selected value selectize.js dropdown

人走茶凉 提交于 2019-12-03 14:29:48
问题 I have a selectize.js dropdown & I have to clear the selected value . I have tried : var selectize = $("#optionNetFlow")[0].selectize; selectize.clear(); as suggested in an another question How do I set the selectize.js option List programmatically . But it gives an error, Uncaught TypeError: Cannot read property 'selectize' of undefinedmessage: "Cannot read property 'selectize' of undefined"stack: (...)get stack: function () { [native code] }arguments: nullcaller: nulllength: 0name: "

Loading values into Selectize.js

邮差的信 提交于 2019-12-03 12:06:13
问题 Problem I have a text input that I have selectized as tags which works fine for querying remote data, I can search and even create new items using it and that all works OK. Using selectize: var $select = $('.authorsearch').selectize({ valueField: 'AuthorId', labelField: 'AuthorName', searchField: ['AuthorName'], maxOptions: 10, create: function (input, callback) { $.ajax({ url: '/Author/AjaxCreate', data: { 'AuthorName': input }, type: 'POST', dataType: 'json', success: function (response) {

How to clear a selected value selectize.js dropdown

[亡魂溺海] 提交于 2019-12-03 04:16:29
I have a selectize.js dropdown & I have to clear the selected value . I have tried : var selectize = $("#optionNetFlow")[0].selectize; selectize.clear(); as suggested in an another question How do I set the selectize.js option List programmatically . But it gives an error, Uncaught TypeError: Cannot read property 'selectize' of undefinedmessage: "Cannot read property 'selectize' of undefined"stack: (...)get stack: function () { [native code] }arguments: nullcaller: nulllength: 0name: ""prototype: StackTraceGetterconstructor: function () { [native code] }__proto__: Object__proto__: function

Creating an item if not already exists in Selectize.js select box and ajax update the new added item

最后都变了- 提交于 2019-12-03 02:57:01
I was using Selectize.js in a select box, What i need is, if an item is not in the list of options i would need to add a new item. When new item is added, i want to have an ajax call to update the newly added item to my database. In their documentiation , it says that we can use "create" to have the selectize to add an item. create - Allows the user to create a new items that aren't in the list of options. This option can be any of the following: "true" (default behavior), "false" (disabled), or a function that accepts two arguments: "input" and "callback". The callback should be invoked with

Loading values into Selectize.js

坚强是说给别人听的谎言 提交于 2019-12-03 01:40:01
Problem I have a text input that I have selectized as tags which works fine for querying remote data, I can search and even create new items using it and that all works OK. Using selectize: var $select = $('.authorsearch').selectize({ valueField: 'AuthorId', labelField: 'AuthorName', searchField: ['AuthorName'], maxOptions: 10, create: function (input, callback) { $.ajax({ url: '/Author/AjaxCreate', data: { 'AuthorName': input }, type: 'POST', dataType: 'json', success: function (response) { return callback(response); } }); }, render: { option: function (item, escape) { return '<div>' + escape

How do I set the selectize.js option List programmatically

爷,独闯天下 提交于 2019-12-02 18:01:39
I know how to set the optionList on Initiliaztion but how do I set it programmatically? I have an inviteList Array. $("#select-invite").options(inviteList); You can use load method to set options via programmatic API . You may also want to call clear and clearOptions methods to reset selected values and old options. Here is how to put it all together: var selectize = $("#select-invite")[0].selectize; selectize.clear(); selectize.clearOptions(); selectize.load(function(callback) { callback(inviteList); }); Please note that inviteList should be an array of objects that have properties configured