I have been out of the jQuery loop recently, and have little exposure with the new data functions in jQuery.
My situation is, I am refactoring an application (using jQuery, of course) which currently makes heavy use of what I can only describe as pseudo-forms; essentially, a page might contain many 'forms', although form tags are rarely used. Instead, the current JS form methods build a query string that is sent via XHR as a GET request. This is partly due to the fact that we use many HTML elements that normally aren't form elements (div's, p's, etc, for various reasons not under my control that I won't go into here), but also because the form elements are not physically close in the HTML structure and so grouping becomes a problem. A basic [mock] scenario: a login 'form', with user/password elements and a 'submit' button. When submit is clicked, it gets the text() of the user and password elements, contructs a query string from them, and then passes this to an XHR call. I am seeking thoughts as to whether -- and if so, how -- the jQuery data functionality could aid me. I do not need to store any "extra" information in the elements (expandos are not the issue here), so I'm not sure if the data functionality would aid me or not. Is there some paradigm whereby I can group non-form elements together, so that I can easily convert the items into a GET (or POST at times), and on the return trip, easily update said related items? I know that I could inject CSS classes for each specific form elements, so that I could use $('.form1') to interact with all the elements of "form1", but this method seems suboptimal. What I was thinking, is created a middle tier that would exist as the data model for the form, and would contain basic methods for submitting/updating/etc. the form. This middle tier would the glue that would tie the data model to the 'form' elements, with the actual HTML elements doing nothing other than displaying what the model dictates, with the model being the de facto source of truth in relation to the data. Is there anything like this already? If not, do you think that the data functionality be a good or bad fit for me? Am I taking the complete wrong approach? Thanks in advance, ken