jQM wraps input
fields in a div ui-input-text
. You need to clone input
itself - not the wrapping div - change its' id
, name
, val()
...etc. Then add it to form
and enhance it using .textinput()
function.
Moreover, you should wrap code in pagecreate
event.
$(document).on("pagecreate", function () {
var counter = 0;
$("#bar").on("input", function (e) {
if ($(e.target).val().length === 1) { /* after 2 characters add a new input */
counter++;
var id = "input-" + counter;
var input = $(e.target).clone().prop({
id: id,
name: id
}).val("");
$(e.target).closest(".ui-input-text").after(input);
$("#" + id).textinput();
}
});
});