You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The binding of selectOptions to a backbone collection involves a call to collection.toJSON. If that function is special, the returned results will not match the expected format. In our case we were wrapping the model JSON in a root element to support old rails conventions.
We found two reasonable fixes: anticipate this JSON structure in the labelPath and valuePath, or remove the custom JSON wrapper and let things happen normally.
I am left with the feeling that Stickit is not very comfortable with backbone objects as bound values rather than bindee. It would feel more robust if evaluatePath was able to do the right thing when obj is a model, so that models could be passed through without serialization. Would you consider a pull request along those lines?
The text was updated successfully, but these errors were encountered:
Sure, I'd love to see what a PR for this looks like. We want to support the common case first and foremost, but not trap ourselves into a situation where we're running into issues with totally reasonable use cases (like yours).
I have a similar issue, where toJSON is custom. Perhaps making an option to choose which function to call to serialize the Collection, and defaulting to toJSON?
The binding of selectOptions to a backbone collection involves a call to
collection.toJSON
. If that function is special, the returned results will not match the expected format. In our case we were wrapping the model JSON in a root element to support old rails conventions.We found two reasonable fixes: anticipate this JSON structure in the labelPath and valuePath, or remove the custom JSON wrapper and let things happen normally.
I am left with the feeling that Stickit is not very comfortable with backbone objects as bound values rather than bindee. It would feel more robust if evaluatePath was able to do the right thing when obj is a model, so that models could be passed through without serialization. Would you consider a pull request along those lines?
The text was updated successfully, but these errors were encountered: