0

I will dynamically add some textbox to my page. It works perfectly, but i get the standart html textbox. I want a textbox in jquery style.

output += "<li><table><form id='elementForm'><tbody>";
output += "<tr><td><label>" + metaLabel[j] + " </label></td>";
output += "<td><input type='text' name='text-1' id='text-1' value=" + ajaxDataRecordSet.recordset[clicked][testVar] + "></td></tr>"
output += "</tbody></form></table></li>";
$(output).appendTo("#content1");
$('#content1').listview('refresh');

How can i do that ?

1
  • I'm using jquery mobile. Commented Jul 22, 2013 at 11:54

2 Answers 2

2

If you are using listview I assume you mean jQuery Mobile? You need to also call textinput() on any input text fields to refresh them:

$("#content1 :text").textinput();

As the documentation for textinput states:

This plugin will auto initialize on any page that contains a textarea or any of the text input types listed above without any need for a data-role attribute in the markup. However, if needed, you can directly call the textinput plugin on any selector, just like any jQuery plugin

Sign up to request clarification or add additional context in comments.

1 Comment

If it doesn't already exist, you can call .trigger("create") on all newly created elements as per Vinod's answer.
2

you have to use $('#elementID').trigger("create") to make it work.

1 Comment

Triggering the create method initializes the listview. At this stage the listview has already been initialized, so he needs to call refresh.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.