English 中文(简体)
我如何在一份清单中把班子添加到有活力的附加形式领域?
原标题:How do I tell jquery mobile to add classes to dynamically added form fields in a listview?

我正在努力使联合后勤部重新启用一个包含形式田的分类表。

其中一个形式要素是作为联合后勤部正常初始化过程的一部分而开始的,正与适用于所有要素的所有正确类别正确显示。

其他人都积极使用JQ的附录

www.un.org/Depts/DGACM/index_spanish.htm 当要素在动态上添加时,我找不到正确的方法,可以重新编制清单,以把ling放在一切方面,实地固然是贴上标签的;案文是:。

我准备了一个例子,以显示我根据在SO和网络周围发现的其他问题所尝试的重新开始要素的不同方法。

http://jsfiddle.net/robaldred/UPsQr/

举例来说,第5行是正确的,但要求打上<条码>的<>菲尔德contain(>方法>textinput() 方法,并人工添加<条码>-投射/标签<>。 标签类别。 这感觉到很多东西,我必须失踪。

最佳回答

• 在该网页上举办一场活动:

$("#page").trigger("create");

www.un.org/Depts/DGACM/index_spanish.htm 创立: 重要区别

Note that there is an important difference between the create event and refresh method that some widgets have. The create event is suited for enhancing raw markup that contains one or more widgets. The refresh method should be used on existing (already enhanced) widgets that have been manipulated programmatically and need the UI be updated to match.

For example, if you had a page where you dynamically appended a new unordered list with data-role=listview attribute after page creation, triggering create on a parent element of that list would transform it into a listview styled widget. If more list items were then programmatically added, calling the listview’s refresh method would update just those new list items to the enhanced state and leave the existing list items untouched.

Referenece:

http://jsfiddle.net/UPsQr/2/“rel=“nofollow” http://jsfiddle.net/UPsQr/2/

问题回答

工作实例:

JS

$( #add_element ).click(function() {
    var list   = $( ul[data-role="listview"] );
    var nextLi = ((list.children().length) + 1);

    li =  <li><div data-role="fieldcontain"><label for="textarea +nextLi+ ">Input:</label><textarea id="textarea +nextLi+ " name="textarea +nextLi+ "></textarea></div></li> ;
    list.append(li);
    list.listview( refresh );

    $( #page ).trigger( create );
});

//$( #add_element ).hide();

传真

<html>
    <head>
    </head>
    <body>
        <div id="page" data-role="page">
            <!-- First field is done by jQM s normal initialization -->
            <!-- The Rest are added onload and appended to the listview -->
            <ul data-role="listview">
                <li>
                    <div data-role="fieldcontain">
                        <label for="textarea1">Input:</label>
                        <textarea id="textarea1" name="textarea1"></textarea>
                    </div>
                </li>
            </ul>
            <a data-role="button" id="add_element">Add Fields</a>
        </div>
    </body>
</html>

注:

jQM Supports j Query 1.6.4





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签