Using $.data in a foreach jquery not working -


Currently, I'm trying to validate several forms on one page. $ Underneath the data (current FormID, "Verifier"); The prices of states that are never hit are not given in any execution path. Is an original work in which it is actually valid.

  Validate: function (option) {// If nothing is selected, do not return anything; If (! This.length) (if (options & amp; options.debug & window.console) {console.warn ("nothing is selected, can not validate, nothing is returning."; } Return;} // works fine in this context var validator = $ .data (this [0], "validator"); $ ("form"). Each (function (index, value) {var currentFormId = ' Form # '+ $ (this) .attr (' id '); // Check that a vedator for this form is already var validator = $ .data (current formid, "validator");}}  

$ .data () we This sign is: $. Data (Element, Key, Value) , where element should be the DOM element, which you want to get / want to set the data. You have CurrentFormId which is a string.

So when you type your .each () :

  // "form # ... '$ Set the data ("validator", current form ID, ID) of the actual form element, "validate";  

If you want to receive data called "validator": < / P>

  var valid = $ .data (this, "validator"); // -> 'Form # ...'  

If you want to get an object with all data assigned to this element:

  var alldata = $ Data (this); // -> Object {Valid = "Form # ...", ......}  


Comments