dynamically inserted form inputs aren't posted

走远了吗. 提交于 2020-01-15 09:33:26

问题


I don't usually actually ask for help, but when I do, believe me I did my research well and found nothing.

Lets make it simple, but relevant.I have a form. Part of it goes like this:

<div class="list-model">
    <div class="connected"><?=$items['connected']?></div>
    <div class="items"><?=$items['items']?></div>
</div>

When somebody clicks an input, i want to move it to another div. I use jQuery for that:

$(".list-model").delegate(".item input", "change", function()
{
    listModel = $(this).closest(".list-model");
    item = $(this).closest(".item");
    insertTo = $(this).is(":checked") ? "connected" : "items";
    insertTo = listModel.find("."+insertTo);
    $(insertTo).append(item);
});

The jQuery works like magic, .item moves back and forth.

BUT

Once I "touch" the actual input, it won't POST!

It won't show in Chrome's Developer Tools under Form Data, nor on the server side.


回答1:


Well... Of course it was my bad.

I'm using an ultra-old framework, in which the form element is "stuck" inside a table element, after <table> but before <tr>.

I took the <form> outside the <table>, so the <form> would wrap the <table> properly, and it worked just fine.



来源:https://stackoverflow.com/questions/17574931/dynamically-inserted-form-inputs-arent-posted

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!