I'm using some generated input elements in my App's form, and I'm trying to keep it simple as possible, that's why I'm sticking with native form reset for them.
It seems that the 'default value' is bonded to the element upon the node creation. For example:
var inputOne = $('<input value="Original value">');
var inputTwo = $('<input>').val('Original value');
myForm.append([inputOne, inputTwo]);
In this example (here's the fiddle) only input one will reset properly, however I need to use something more like was done in input two because I have different kinds on input templates that are much more complex than those in the example given, so a simple string concatenation with the value is not a much viable option.
I've considered to use placeholders in my input templates, like:
var myInputTemplate = '<input value="%val" data-foo="%foo" data-bar="%bar">';
var newInputNode = createNodeFromTemplate(myInputTemplate , {
val: "Original Value",
foo:"My Foo",
bar:"My Bar",
});
But that's a last resort, remember I'm trying to keep it simple as possible.
The question:
I read once in the spec that the default value is defined differently for each element type, but no further explanation was given.
How default values are defined for inputs?!
There's some workaround to "redefine" the default value in generated inputs?!
$('<input />', {value: 'Original value'})pass an object