selectize.js

Capybara integration tests with jquery.selectize

徘徊边缘 提交于 2019-12-01 16:53:39
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. 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_selectized('candidate_offices', 'Santa Monica') # Multiple values fill_in_selectized('candidate_offices', ['San

How to set a value for a selectize.js input?

帅比萌擦擦* 提交于 2019-11-30 02:37:53
I have a form from which I would like to copy some default values into the inputs. The form inputs are using the selectize.js plugin. I would like to set some of the form values programatically. The standard way of doing this: $("#my_input").val("My Default Value"); does not work. I have tried something like this but it does not work either. var $select = $("#my_input").selectize(); var selectize = $select[0].selectize; selectize.setValue("My Default Value"); Any ideas? It's got to be easy :) I'm missing it. Check the API Docs Methods addOption(data) and setValue(value) might be what you are

Selectize.js manually add some items

て烟熏妆下的殇ゞ 提交于 2019-11-29 02:50:38
I want add some items to a selectized input after user clicks on a button. The input data are loaded via Ajax. When I call addItem(value) no thing happens. But if I try to type some string in the input it loads data and after this addItem(value) will works. https://github.com/brianreavis/selectize.js/blob/master/docs/api.md This plugin does not attempt to load an item metadata from the server. You need to first add an option using addOption() method. Next, you can use addItem() . v.selectize.addOption({value:13,text:'foo'}); //option can be created manually or loaded using Ajax v.selectize

Selectize.js manually add some items

為{幸葍}努か 提交于 2019-11-27 17:06:53
问题 I want add some items to a selectized input after user clicks on a button. The input data are loaded via Ajax. When I call addItem(value) no thing happens. But if I try to type some string in the input it loads data and after this addItem(value) will works. https://github.com/brianreavis/selectize.js/blob/master/docs/api.md 回答1: This plugin does not attempt to load an item metadata from the server. You need to first add an option using addOption() method. Next, you can use addItem() . v

How to set a value for a selectize.js input?

吃可爱长大的小学妹 提交于 2019-11-27 12:53:52
问题 I have a form from which I would like to copy some default values into the inputs. The form inputs are using the selectize.js plugin. I would like to set some of the form values programatically. The standard way of doing this: $("#my_input").val("My Default Value"); does not work. I have tried something like this but it does not work either. var $select = $("#my_input").selectize(); var selectize = $select[0].selectize; selectize.setValue("My Default Value"); Any ideas? It's got to be easy :)