what is the best way to create MVC architecture in jQuery?
Should I use jQuery.extend()?
jQuery.extend({
View: function(){}
});
...or jQuery Plugin?
(function($) {
$.fn.model = function() { return this; };
})(jQuery);
...or just objects in JavaScript?
var model = {}
var view = {}
var controller = {}
Thank you!
Building Web Applications with ASP.NET Core 3 MVCThe MVC Framework contains built-in support for unobtrusive Ajax. You can use the helper methods to define your Ajax features without adding a code throughout all the views. This feature in MVC is based on the jQuery features.
MVC stands for Model-View-Controller. It's a design pattern that breaks an application into three parts: the data (Model), the presentation of that data to the user (View), and the actions taken on any user interaction (Controller).
It is a client-side script that communicates to and from a server/database without the need for a postback or a complete page refresh. The Ajax speeds up response time. In other words, Ajax is the method of exchanging data with a server, and updating parts of a web page, without reloading the entire page.
js is a JavaScript framework that implements the MVC architecture. Events/input from the View is sent to the Controller where they're processed and data sent to the Model.
Just use objects in javascript. The view can contain all the knowledge of things like jquery and other UI concerns, while the controller/model can deal with other logic and communication with the server (assuming ajax). I wrote a blog post about this:
MVC Pattern with Javascript
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With