Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upExample of create? #992
Example of create? #992
Comments
I found this while I was having similar issues: I have a selectize attached to a pre-populated select input, but I wanted to add a create method. I was able to create the item but it wasn't being added to the control. I was able to fix this by adding a |
Ah, tricky. Thanks for the feedback. I basically ended up removing selectize.js, as it was adding unnecessary complexity for the feature - a basic select box ended up being sufficient. |
Ah fair enough - I thought I'd comment for posterity in case anyone else came this way. Thinking about it a little more last night, I think this is most likely due to me using coffeescript: by default CS returns the last statement (like Ruby), and I think if I were using plain javascript I wouldn't have had this problem. In the selectize code there is a check for the return value of the create function: if you don't return anything then this would just work, but obviously in coffeescript it does it behind the scenes which caused my confusion. |
I also had hard time figuring this out, I'm using coffeescript so returning something at the end of each function is normal behavior. Could this be avoided by checking if a callback is specified in the function arguments? Or by always adding/updating the item when the callback is called? I'm figuring the latter is also useful to allow the action to persist on the client, and update once we got the result from the server (such as adding important information as resource ID) |
Thanks @chickenboot I also had this (coffee-related) issue |
I am having difficulty understanding how to use the
create
function callback. I have found one StackOverflow post describing create callback functions, but am not able to get the create callback to work, as the tag is not inserted back into the select array.Is there a functional example of how to use the create method with a callback function?