I parse the JSON response through $.ajax() and build the form from these object values. I wrote a script for a long time, but here is what it does:
Dynamic creation:
~ form element
~ field set item,
~ button element,
~ 20 or so text inputs and label elements
Adding inputs and labels to a set of fields
Adding a Button to a Field Set
Adding a field set to a form
- Adding a form to an element of an existing DOM.
Everything works in all browsers, except for one small fragment in IE. I narrowed it down to the next code snippet. ( doc is a variable containing document )
fieldset.append( $(doc.createElement('button')) .addClass('ui-button') .attr('type', 'submit') .html('Re-Rate') .button() );
This is step 3 above. It creates a button element, adds a class, sets the type attribute to submit , gives it some text, and then adds it to the set of fields. IE with an error "Object does not support this action"
If I comment out the .attr() as follows:
fieldset.append( $(doc.createElement('button')) .addClass('ui-button') //.attr('type', 'submit') .html('Re-Rate') .button() );
Everything works as expected.
If you're interested, the .button() method is a jQuery UI
javascript jquery dom internet-explorer attributes
Stephen
source share