Hi guys I have looked through the knockoutjs and backbone, and could not understand the benefits of using them. One advantage is to reduce the traffic between client and server, but other side of coin is maintainance of the code. Using the code with javascript
binding can be very tricky. The using server side is just for JSON string generation - I don't think it is wise architecture approach. May be, it can be helpfull for views on different clients like mobile vs not-mobile, but, as for me, it is overkill - the
client implementation will require the new server methods. What are your suggestions?
I can't speak for Backbone, but KO is quite useful. Imagine you're building a very javascript (and prolly jQuery) heavy web page. You're writing all this JS to populate the UI elements. You might also have to handle changes to the data from the user, so
you're writing lots of change event handlers to know when the input elements are updated. Imagine then that you have read only parts of the page that need to be updated when the input elements have changed. Writing all of the code to update the UI, handle
change events, and then know if input element A changed that you then have to keep element B in sync... that's all quite a bit of messy code. KO helps manage this by using the MVVM abstraction model -- with observables and their framework for binding the VM
to the UI.
I had a fairly large javascript heavy app I built about 2-3 years ago and I wish I had KO back then. Would have made the app/code/logic much cleaner.
The thing you might "hate" is that ko move some "logics" into the html page....so it might appear it breaks the separation of concerns between graphics and logics....Actually separation of concerns is not broken...but the boundary is moved to the client,so
the same Html page is broken in two parts ...logics and graphics. However graphics is separated from logics in ko, and the link between them is done through the ko bindings.
Give a look to Mvc Controls Toolkit
client blocks. They compute automatically ko bindings, so you don't need to put any code in the html page...all code can be put into js files, and bindings...are just computed automatically based on the same name convention used by MVC...maximum of separation.
You need just to apply some click binding ro handle buttons and some ccs and style bindings if you hneed to change the appearence of Html nodes according to the values of data.
vladnech
Member
175 Points
78 Posts
Benefits in JavaScript model binding?
May 05, 2012 03:57 PM|LINK
BrockAllen
All-Star
28042 Points
4991 Posts
MVP
Re: Benefits in JavaScript model binding?
May 05, 2012 04:03 PM|LINK
I can't speak for Backbone, but KO is quite useful. Imagine you're building a very javascript (and prolly jQuery) heavy web page. You're writing all this JS to populate the UI elements. You might also have to handle changes to the data from the user, so you're writing lots of change event handlers to know when the input elements are updated. Imagine then that you have read only parts of the page that need to be updated when the input elements have changed. Writing all of the code to update the UI, handle change events, and then know if input element A changed that you then have to keep element B in sync... that's all quite a bit of messy code. KO helps manage this by using the MVVM abstraction model -- with observables and their framework for binding the VM to the UI.
I had a fairly large javascript heavy app I built about 2-3 years ago and I wish I had KO back then. Would have made the app/code/logic much cleaner.
DevelopMentor | http://www.develop.com
thinktecture | http://www.thinktecture.com/
francesco ab...
All-Star
20954 Points
3284 Posts
Re: Benefits in JavaScript model binding?
May 05, 2012 07:43 PM|LINK
The thing you might "hate" is that ko move some "logics" into the html page....so it might appear it breaks the separation of concerns between graphics and logics....Actually separation of concerns is not broken...but the boundary is moved to the client,so the same Html page is broken in two parts ...logics and graphics. However graphics is separated from logics in ko, and the link between them is done through the ko bindings.
Give a look to Mvc Controls Toolkit client blocks. They compute automatically ko bindings, so you don't need to put any code in the html page...all code can be put into js files, and bindings...are just computed automatically based on the same name convention used by MVC...maximum of separation. You need just to apply some click binding ro handle buttons and some ccs and style bindings if you hneed to change the appearence of Html nodes according to the values of data.
Mvc Controls Toolkit | Data Moving Plug-in Videos