I have been looking into various design patterns and trying to architect client side applications using it. More often than not the MVC pattern fits the requirement in most of the applications. However, I have found myself using MVVM (Model View - View Model) pattern along with MVC. I use MVVM pattern particularly when I have to maintain the state of the model on the client side. AngularJS provides great support by allowing you to extend the markup and tying the model right within the view (the markup). It also provides components that can be used to structure the application the MVC way and hence it's appropriately termed as MVW or MV* framework. However, I use BackboneJS in most of my applications and I have been able to maintain the state of the model using the Backbone.Stickit plugin.
When working with Backbone applications, the View's sole responsibility would be to render the model data and also re-render the parts of the view when the state of the model changes. The View listens to the model changes and executes a callback function when the state of the model has changed:
Here in the Backbone View's initialize method, the View is listening to the change in one the model's attribute and it executes the 'updateView' method whenever the 'modelAttribute' is updated. The 'updateView' function then refers to one of the nodes in the View and updates it with the value in 'modelAttribute'. This pattern can be repeated for various attributes in the model and the view can have several functions whose only responsibility is to update a DOM node in the View.
Similarly, when the user inputs data in form elements the same should be reflected in the model. To do that the View will have to declare event handlers:
This has to be repeated for other View elements and developer will be required to write boilerplate code. An alternative to this is to use a Backbone plugin called 'Stickit'. Backbone.Stickit abstracts the above functionality and provides a more cleaner way to bind the View's elements to the model's attributes. In a Backbone View you can define the binding between the model's attributes with the elements in the markup using the 'bindings' object:
Here in the bindings object, the keys are the View elements and the attributes in the model are specified as values. For example, the view element '.js-full-name' is bound to the model attribute 'fullName'. The bindings object provides a two way binding between the View elements and Model attributes. This means that whenever the user inputs some value in the form elements the Model attributes are updated and whenever the Model attribute is updated by some part of the application or by a service call the View elements are updated.
Once the View has compiled the client-side template and rendered it, the View elements should be bound to the Model's attributes. To do that invoke the stickit method on the view object (view.stickit()). I generally use the postRender method and invoke it after the render method has been executed. As the name suggests, the postRender method would execute a set of actions after rendering the template. In this case, call stickit on the view object - this.stickit(); where this refers to the current view.
The Stickit plugin provides several options to configure the bindings. I'll explain those in my next post.
When working with Backbone applications, the View's sole responsibility would be to render the model data and also re-render the parts of the view when the state of the model changes. The View listens to the model changes and executes a callback function when the state of the model has changed:
Here in the Backbone View's initialize method, the View is listening to the change in one the model's attribute and it executes the 'updateView' method whenever the 'modelAttribute' is updated. The 'updateView' function then refers to one of the nodes in the View and updates it with the value in 'modelAttribute'. This pattern can be repeated for various attributes in the model and the view can have several functions whose only responsibility is to update a DOM node in the View.
Similarly, when the user inputs data in form elements the same should be reflected in the model. To do that the View will have to declare event handlers:
This has to be repeated for other View elements and developer will be required to write boilerplate code. An alternative to this is to use a Backbone plugin called 'Stickit'. Backbone.Stickit abstracts the above functionality and provides a more cleaner way to bind the View's elements to the model's attributes. In a Backbone View you can define the binding between the model's attributes with the elements in the markup using the 'bindings' object:
Here in the bindings object, the keys are the View elements and the attributes in the model are specified as values. For example, the view element '.js-full-name' is bound to the model attribute 'fullName'. The bindings object provides a two way binding between the View elements and Model attributes. This means that whenever the user inputs some value in the form elements the Model attributes are updated and whenever the Model attribute is updated by some part of the application or by a service call the View elements are updated.
Once the View has compiled the client-side template and rendered it, the View elements should be bound to the Model's attributes. To do that invoke the stickit method on the view object (view.stickit()). I generally use the postRender method and invoke it after the render method has been executed. As the name suggests, the postRender method would execute a set of actions after rendering the template. In this case, call stickit on the view object - this.stickit(); where this refers to the current view.
The Stickit plugin provides several options to configure the bindings. I'll explain those in my next post.
NICE...INTERNSHIP PROGRAM FOR BSC STUDENTS
ReplyDeleteFINAL YEAR PROJECT IDEAS FOR INFORMATION TECHNOLOGY
CCNA COURSE IN CHENNAI
ROBOTICS COURSES IN CHENNAI
INTERNSHIP IN CHENNAI FOR ECE
CCNA TRAINING IN CHENNAI
PYTHON INTERNSHIP IN CHENNAI
INDUSTRIAL VISIT IN CHENNAI
INTERNSHIP FOR CSE STUDENTS IN CHENNAI
ROBOTICS TRAINING IN CHENNAI
good information..
ReplyDeletePython Internship
Dotnet Internship
Java Internship
Web Design Internship
Php Internship
Android Internship
Big Data Internship
Cloud Internship
Hacking Internship
Robotics Internship
REALY NICE INFORMATION..
ReplyDeleteOracle Internship
R Programming Internship
CCNA Internship
Networking Internship
Artificial Intelligence Internship
Machine Learning Internship
Blockchain Internship
Sql Server Internship
Iot Internship
Data Science Internship
GOOD POST....
ReplyDeleteSelenium Testing Internship
Linux Internship
C Internship
CPP Internship
Embedded System Internship
Matlab Internship
good
ReplyDeleteFree Internship for cse students in Chennai
R Programming Internship
Hadoop Training in Chennai
Free Internship Training in Chennai
Robotics Training chennai
Summer Internship For BSC students
Internships in Chennai for CSE
CCNA Institute in Chennai
Data Science Internship in Chennai
Aeronautical Engineering Internship
good
ReplyDeleteGeteventlisteners javascript
Karl fischer titration interview questions
How to hack tp link router
T system aptitude questions
Resume for bca final year student
Test case for railway reservation system
T systems pune placement papers
Infrrd bangalore interview questions
Max number in javascript
Paypal integration in php step by step pdf
GREAT...
ReplyDeleteFREE Internship in Nagpur For Computer Engineering Students
Internship For MCA Students
Final Year Projects For Information Technology
Web Design Class
Mechanical Engineering Internship Certificate
Inplant Training For Mechanical Engineering Students
Inplant Training Certificate
Ethical Hacking Course in Chennai
Winter Internship For ECE Students
Internships For ECE Students in Bangalore
NICE...
ReplyDeleteHow To Hack On Crosh
Request Letter For Air Ticket Booking To HR
Zeus Learning Aptitude Paper For Software Developer
Cimpress Interview Questions
VCB Rating
Appreciation Letter To Vendor
JS MAX Safe Integer
Why Do You Consider Yourself Suitable For The Position
How To Hack Android Phone From PC
About Bangalore Traffic Essay
good
ReplyDeletehacking course
internship for it students
civil engineering internship report pdf india
ccna course chennai
internship report for civil engineering students in india
internships in hyderabad for cse students 2018
kashi infotech
cse internships in hyderabad
inplant training for diploma students
internship in hyderabad for cse students
good
ReplyDeletenodejs while loop
icici bank po interview questions and answers pdf
craterzone aptitude test
zensoft recruitment process
java developer resume 1 years experience
python developer resume pdf
infrrd private limited interview questions
js int max value
delete * from table oracle
t systems pune aptitude questions
GREAT VERY INFORMATIVE
ReplyDeleteInternship For Aerospace Engineering
Mechanical Engineering Internships in Chennai
Robotics Courses
Kaashiv
Training Letter Format For Mechanical Engineer
Internship For BCA Student
Fake Internship Certificate
MBA Internship
Free Internship For CSE Students in Chennai
Oracle Internship 2020
NICE INFORMATION
ReplyDeleteJavascript Maximum Integer
INT MAX Javascript
Acceptance is to an Offer What a Lighted Match is to a Train of Gunpowder
Who Can Issue Character Certificate
Technical Support Resume DOC
PHP Developer Resume For 3 Year Experience
Wapda Interview Questions
Power BI Resume Download
a Dishonest Dealer Professes to Sell His Goods at a Profit of 20
Failed to Find 'Android_Home' Environment Variable. TRY Setting it Manually
good
ReplyDeleteiot training in coimbatore
summer training for 3rd year electronics and communication engineering students
goa current affairs 2019
project for information technology students
online internship for bca students
winter training for mechanical engineering students
ccna training
industrial training report for electronics and communication pdf
matlab courses in chennai
bba internship project
good nice
ReplyDeleteResume Format For Bca Freshers
British Airways Interview Questions And Answers Pdf
Asus Tf101 Android 8
Crome://Flags/
T Systems Aptitude Test
Python Resume Ror 2 Years Experience
Ajax Redirect To Another Page With Post Data
Paramatrix Technologies Aptitude Questions And Answers
Adder Subtractor Comparator Using Ic 741 Op-Amp Theory
How To Hack Wifi With Ubuntu
ReplyDeleteGreat Article
Final Year Projects for CSE in Angular
Angular Training in Chennai
Project Centers in Chennai
JavaScript Training in Chennai
nice blogs...
ReplyDeleteinternship for ece students in bangalore
internship for cse students in hyderabad
internship for cse students in hyderabad
artificial intelligence internship
internship in bangalore for be cse students
internship in pune for computer engineering students
free internship in chennai
internship
internship for bsc students
android training in chennai
This comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDeletegood..!
ReplyDeleteinternship training in chennai
ethical hacking internship
hacking internship
civil internship in chennai
internships in chennai for cse students
architecture firms in chennai for internship
internships for cse students in chennai
free internship for cse students
internships in hyderabad for cse students 2020
in plant training in chennai
nice post.....!!
ReplyDeletepoland web hosting
russian federation web hosting
slovakia web hosting
spain web hosting
suriname
syria web hosting
united kingdom
united kingdom shared web hosting
zambia web hosting
inplant training in chennai
nice information......
ReplyDeleteapache solr resume sample
apache spark sample resume
application developer resume samples
application support engineer resume sample
asp dotnet mvc developer resume
asp net core developer resume
asp net developer resume samples
assistant accountant cv sample
assistant accountant resume
assistant accountant resume sample