jQuery clone()表单提交不按预期工作

时间:2018-03-29 08:20:22

标签: jquery html clone

当我克隆表单并想要提交克隆表单时,它会提交父表单。 我更新了这个问题。

   var mainPart = wDoc.MainDocumentPart;

                        var res = from bm in mainPart.Document.Body.Descendants<BookmarkStart>()
                                  where bm.Name == "vendos_tekstin"
                                  select bm;
                        var bookmark = res.SingleOrDefault();
                        if (bookmark != null)
                        {
                            var parent = bookmark.Parent;   // bookmark's parent element

                            // build paragraph piece by piece
                            Text text = new Text(DateTime.Now.ToString() + " , ");
                            Text text1 = new Text(gjenerimi + " , ");
                            Text text2 = new Text(merreshifren());
                            var run = new Run();
                            run.Append(text,text1,text2);
                            Paragraph newParagraph = new Paragraph(run);
                            run.PrependChild<RunProperties>(runProp);
                            // insert after bookmark parent
                            parent.InsertAfterSelf(newParagraph);

http://jsfiddle.net/zMYVq/552/

2 个答案:

答案 0 :(得分:0)

您可以尝试下面的内容,

<div class="cl">
<form id="myform_1">
    <input type="text" name="field1" />
    <br/>
    <input type="text" name="field2" />
    <br/>
    <input type="submit" class="submit"/>
</form>
</div>

我刚刚为您的提交按钮分配了一个课程

export const signIn = ( action$, state ) => {
    return action$
        .ofType(types.SIGN_IN_REQUEST)
        .switchMap(( { params, } ) => (services.signInRequest( // it is ajax observable
                        mappers.mapSignInRequest(params)
                    ))
        .map(response => actions.signInJWTSuccess( // dispatch success
                        mappers.mapUser(response)
                    ))
        .catch(error => of(actions.signInError( // dispatch error
                        mappers.mapSignInError(error)
                    )))
};

答案 1 :(得分:0)

        function onValidate(val){

           $('#'+val).each(function(key, form) {

                 $(form).validate({ //intit plugin
                    rules: {
                        field1: {
                            required: true
                        },
                        field2: {
                            required: true
                        }
                    },
                    submitHandler: function (form) { 
                        alert('valid form submitted'); 
                        return false; 
                    }
                });
             });
        }

        $(document).ready(function () {
        var i=1;
            $('body').on('click','input[type="submit"]',function(e) {  
                        e.preventDefault();
                        $(this).closest('form').submit();

                     });
             $('#clone').click(function(e) {
                       e.preventDefault();
                       i++;

                       $('#myform_1').clone(false).prop('id','myform_'+i ).appendTo('.clone');
                       onValidate( 'myform_'+i);

                     });


          onValidate("myform_"+i);
         });