简体   繁体   English

symfony jquery原型动态表格

[英]symfony jquery prototype dynamic form

I am trying to realize a dynamic form with possibility to add\\remove fields (just add for now cause it doesn't work). 我正在尝试实现一种动态窗体,可以添加\\删除字段(暂时添加,因为它不起作用)。 I am working with Symfony 2.0.13, and following the guide at Here but the result is that i can't obtain the 我正在使用Symfony 2.0.13,并按照此处的指南进行操作,但结果是我无法获得

<a href="#" class="add_tag_link">Add a tag</a>

in the rendered html, as you can see Here #2 在呈现的html中,如您在此处看到的#2

Has anyone a clue? 有任何线索吗?

just change the script to 只需将脚本更改为

jQuery(document).ready(function() {

 // Get the div that holds the collection of tags
var collectionHolder = $('ul.tags');

// setup an "add a tag" link
var $addTagLink = $('<a href="#" class="add_tag_link">Add a tag</a>');
var $newLinkLi = $('<li></li>').append($addTagLink);


    // add the "add a tag" anchor and li to the tags ul
    collectionHolder.append($newLinkLi);

    $addTagLink.on('click', function(e) {
        // prevent the link from creating a "#" on the URL
        e.preventDefault();

        // add a new tag form (see next code block)
        addTagForm(collectionHolder, $newLinkLi);
    });
});

this will work... 这将工作...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM