Title: Validatebox validation on dynamically created from elements Post by: sm_79 on July 06, 2014, 01:14:33 PM Hi,
I am using jquery easyui validatebox for validating data in my form. However, in one of the forms, there is scope to create a group of form elements dynamically by clicking 'add elements' button. Code: <fieldset id="teacher_2"> On clicking the 'add teacher' button, basically I am using jquery .clone() method to create a copy of the div with class 'clonedInputTch'. As you can see, I have used "easyui-validatebox" class for validation of the form elements. When there is only set of form elements, the validation is working fine. However, once a new set of fields have been generated dynamically, the validation is not working. And at this point getting following error in console: Code: Uncaught TypeError: Cannot read property 'options' of undefined jquery.easyui.min.js:5943 Thanks in advance. Title: Re: Validatebox validation on dynamically created from elements Post by: stworthy on July 06, 2014, 05:43:29 PM Please call $.parser.parse function to parse the validatebox components after generating elements.
Code: var ff = $('#tchentry1').clone().attr('id','').appendTo('#teacher_2'); Title: Re: Validatebox validation on dynamically created from elements Post by: globule on July 17, 2014, 08:25:03 AM Hmmm... and how can I do if have 2 forms and once the first is validated (ajax submit to check availability), all the fields in the first form are injected (prepend) into the second ?
Actually, only the first form is correctly validated but the second returns Code: Cannot read property 'options' of undefined Code: $('#formCreate2').form({ Title: Re: Validatebox validation on dynamically created from elements Post by: sm_79 on July 20, 2014, 08:39:47 AM Please call $.parser.parse function to parse the validatebox components after generating elements. Code: var ff = $('#tchentry1').clone().attr('id','').appendTo('#teacher_2'); Thanks a lot. This solves the issue I mentioned. However, it creates one side effect...if my form has a combo box as below: Code: <input type="text" id="locCode" name="loc" class="form-control easyui-combobox" placeholder="Location Code" On executing $.parser.parse(ff); it is un-setting the user selected value from combobox. Can you suggest any fixes for this? Thanks again in advance. Title: Re: Validatebox validation on dynamically created from elements Post by: stworthy on July 20, 2014, 05:20:40 PM Please set the 'value' property for combobox to set the initialized value.
Code: <input type="text" id="locCode" name="loc" class="form-control easyui-combobox" value="..." ...> Code: [{ Title: Re: Validatebox validation on dynamically created from elements Post by: sm_79 on January 24, 2015, 05:01:21 PM Please set the 'value' property for combobox to set the initialized value. Hi,Code: <input type="text" id="locCode" name="loc" class="form-control easyui-combobox" value="..." ...> Code: [{ Sorry about reviving this old topic. But I am stuck again at a similar problem. You have suggested to set the value or set selected property to 'true' in json array. But if this is not an edit form, I simply need to load the data in the combobox with no pre-defined initialized value. Now if user selects a value from the combobox for inserting in DB for first time, on submit I am executing $.parser.parse(ff); but it is un-setting the user selected value from combobox. Please advise on how this can be resolved. Thanks in advance. |