Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation is very unclear about how to add options #745

Closed
nickretallack opened this issue Mar 21, 2015 · 7 comments
Closed

Documentation is very unclear about how to add options #745

nickretallack opened this issue Mar 21, 2015 · 7 comments

Comments

@nickretallack
Copy link

All the documentation says is:

An array of the initial available options. type: array

Naturally, I thought this would be sufficient:

$('#test').selectize({options:['cat','dog','snake']});

However, it turns out I have to do this:

$('#test').selectize({options:[{text:'cat',value:'cat'},{text:'dog',value:'dog'},{text:'snake',value:'snake'}]});

I was only able to figure this out by looking at the definition of "create" in the example on the home page. The documentation should be clearer about the schema of options.

Also, I don't see why it shouldn't accept ['cat','dog','snake'] or even 'cat,dog,snake' with a little introspection, considering it allows things like this in the value field of a text input.

@therocode
Copy link

I second this one. I had to google for an example on Stack Overflow. I had similar issues with other functions in the documentation, such as "setValue(value, silent) Resets the selected items to the given value." - it never specifies that a 'value' is actually the 'value' part of an option pair.

Perhaps it could have a section where it defines all these things.

@brianreavis
Copy link
Member

Open to pull requests.

@nickretallack
Copy link
Author

Hey, why was this closed? What's the resolution on this?

@brianreavis
Copy link
Member

Because an issue is not the solution to something so trivial – this is what pull requests are for. I'm in agreement that it could be improved, and am open to fixes... I just don't have time currently to do it myself and am not open to more actionless +1's. Related: #752.

@PhiLhoSoft
Copy link
Contributor

I agree on both fronts: documentation could be improved, I stumbled upon some sketchy descriptions here and there (and I felt into the trap described above, like many people I guess); and it is the work of contributors to improve it, I think. At least, that's why I forked the project...
(I have myself written recently a comment on an issue telling a trick about placeholder should be documented. Something I should fix myself, I suppose...)

PhiLhoSoft added a commit to PhiLhoSoft/selectize.js that referenced this issue May 3, 2015
- Some typo fixes
- Fixes selectize#779, selectize#745, selectize#464 and perhaps some others
joallard pushed a commit that referenced this issue Jul 6, 2016
- Some typo fixes
- Fixes #779, #745, #464 and perhaps some others

(Markdown doesn't work inside tables :-( )
joallard pushed a commit that referenced this issue Jul 20, 2016
Closes #785 [skip-ci]

- Some typo fixes
- Fixes #779, #745, #464 and perhaps some others

(Markdown doesn't work inside tables :-( )
bwilson-ux pushed a commit to bwilson-ux/selectize.js that referenced this issue Oct 4, 2016
Closes selectize#785 [skip-ci]

- Some typo fixes
- Fixes selectize#779, selectize#745, selectize#464 and perhaps some others

(Markdown doesn't work inside tables :-( )
@StevenWillett
Copy link

For anyone else that comes across this like me, there is now excellent documentation for Selectize API here: https://github.com/selectize/selectize.js/blob/master/docs/api.md

@satnambajwa
Copy link

$('#id').selectize({
create: function(input,callback){
$.ajax({
url: "",
type: "POST",
data: {value : input},
success: function(res) {
callback({value: res, text: input});
}
});
}
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants