-
Notifications
You must be signed in to change notification settings - Fork 300
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
Validation with 2 views using the same model #140
Comments
I don't see why it shouldn't work, but I haven't tried it myself. If you -Thomas P On 19. juni 2013, at 19:14, "Sébastien Deleuze" [email protected] I don't know if it is (1) currently possible, (2) a possible evolution or Backbone is designed to allow this easily thanks to binding on model or — |
I was wondering about conflict on view1.model and view2.model if I do : Or was wondering if validation should be disabled on both views as soon as I unbind of them : I will try ... |
Issue confirmed, you can test it with the example from https://github.com/sdeleuze/backbone.validation/tree/issue140 It works with : It fails with : Any thoughts ? |
Running into this issue as well. I have several views that operate on the same model. Fixing this is not super simple. It would require changing the |
I'm also running into this issue. I have one model that's used by several different views. For instance, I have a view that displays an input for username. I have separate views for email address, passwords, etc. In my own use case, each one of these views need to be separated with their own display logic, so having only one view isn't an option. These all use the same model and all these views have validation rules set up on the model. All the model attributes still validate correctly when Based on this fiddle, the Terms of Use view is the only one bound. In the View the console to verify the |
I have a project where I need to do something similar. I haven't verified this but I am going to try just using Validation mix-in and then write some glue code to get the views to render the errors. |
@SomethingSexy, I have found a solution for this issue and have implemented it in a few of my projects and can verify it works. Check out this fiddle: http://jsfiddle.net/wesleymusgrove/CyJ2y/ According to the documentation, I'm mixing in the Validation with the Model's prototype:
Backbone Marionette's EventAggregator was the "glue code" I chose to use in order to get all my different views to listen for model validation events.
Firstly, the
After that, I'm calling
In response to the
Looking at the fiddle, you can see that each view extends from BaseView and is listening for those
The
I encourage you to check out the fiddle and let me know if you see any issues or improvements. |
I don't know if it is (1) currently possible, (2) a possible evolution or (3) imposible by design, but is it possible to validate 2 views using the same model and displayed at the same time ?
Backbone is designed to allow this easily thanks to binding on model or collection, but is it possible with current Backbone.Validation.bind and Backbone.Validation.unbind behaviour ?
The text was updated successfully, but these errors were encountered: