Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3722482
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T05:55:15+00:00 2026-05-19T05:55:15+00:00

Note: This is a long winded question and requires a good understanding of the

  • 0

Note: This is a long winded question and requires a good understanding of the MVVM “design pattern”, JSON and jQuery….

So I have a theory/claim that MVVM in DHTML is possible and viable and want to know if you agree/disagree with me and why. Implementing MVVM in DHTML revolves around using ajax calls to a server entity that returns JSON and then using html manipulation via javascript to control the html.

So to break it down. Lets say I’m building a search page that searches for People in a database…..

The View would look something like this:

    
        <body viewmodel="SearchViewModel">
            Search:<br />
            <input type="text" bindto="SearchString" /><br />
            <input type="button" value="Search" command="Search" />
            <br />
            <table bindto="SearchResults">
                <thead>
                    <tr>
                        <th>First Name</th>
                        <th>Last Name</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>${FirstName}</td>
                        <td>${LastName}</td>
                    </tr>
                </tbody>
            </table>
        </body>
    

Using some non standard attributes on my html elements, I have declaritively defined a View and how it will interact with my ViewModel. I’ve created a MVVM parser in javascript that interprets the non-standard attributes and associates the View with a JSON object that represents the ViewModel.

The ViewModel would be a JSON object:

    
        //View Model SearchViewModel would be assocaited with View because of <body viewmodel="SearchViewModel">
        var SearchViewModel = {
            //SearchString variable has a TwoWay binding 
            //to <input type="text" bindto="SearchString" /><
            //if a user types into the text box, the SearchString property will "auto-magically" be updated
            //because of the two way binding and how the element was interpreted via my MVVM parser
            SearchString: '',

            //SearchResults has a OneWay binding to <table bindto="SearchResults">
            SearchResults: new Array(), 

            //Search function will get "auto-magically" get called because of 
            //the command binding to <input type="button" command="Search" />
            Search: function() {
               //using jquery to call into the server asynchronously
               //when the server call is completed, the PopulateSearchResults method will be called
               $.getJSON("www.example.com/SearchForPerson",
                         { searchString: SearchViewModel.SearchString },
                         SearchViewModel.PopulateSearchResults);
            }

            PopulateSearchResults: function(data) {
                //set the JSON array
                SearchViewModel.SearchResults = data;
                //simulate INotifyPropertyChanged using the MVVM parser
                mvvmParser.notifyPropertyChanged("SearchResults");
            }
        }
    

The Model can be any server side asset that returns JSON…in this example, I used asp MVC as a restful facade:

    
        public JsonResult SearchForPerson(string searchString)
        {
            PersonDataContext personDataContext = new PersonDataContext(); //linq to sql.....

            //search for person
            List<Person> results = 
                personDataContext.Persons
                                 .Where(p => p.FirstName.Contains(searchString)
                                             || p.LastName.Contains(searchString))
                                 .ToList();

            return Json(results);
        }
    

So, again the question:
Is MVVM possible/viable in a DHTML RIA application (no Silverlight/WPF) or have I lost my mind?

Could this “MVVM framework” be a good idea?

Proof of Concept: kaboom.codeplex.com.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T05:55:16+00:00Added an answer on May 19, 2026 at 5:55 am

    This would probably be a good time to link to knockout JS, which is a javascript mvvm framework.

    You may also want to look at backbone, a javascript MVC framework:

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

NOTE: This is a followup to my question here. I have a program that
Note: This question has broadened in scope from previous revisions. I have tried to
NOTE: This is a long question. I've explained all the 'basics' at the top
(Edited) NOTE: this question is NOT about how Eclipse's code formatter wrap long String
Hopefully this won't be too long-winded, but trying to be complete: So I have
note: this is a direct follow up to this previous question I have very
(Note: This is not a question about what is the best way with code
NOTE: This is an old question and the answers here no longer works (since
Note: this question has nothing to do with Knockout.js, but it's about the selectedOptions
Note this question was originally posted in 2009, before C++11 was ratified and before

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.