获取与表单操作有关的部分

实际上,当我单击“提交”按钮时,该元素显示在jequery对话框中。

当我单击“提交”按钮时,我需要(在同一页面中)获得引用表单动作的div元素。 这是我的ajax:

$('body').on('submit','#PasswordResetform',function(e){ 
                                e.preventDefault(); 
                                var actionurl = e.currentTarget.action; 
                                var postData = $("#PasswordResetform").serialize() + "&"+ jQuery(this).attr("name") + "=submit";

                                var url = $(this).attr('action');
                                $.ajax({
                                    type: "POST",url: url,data: postData,success: function(data) { 
                                        var htmll = $(data).find('.resetPasswordConfirm');
                                        // console.log("postData",postData);
                                        // console.log("url",url);
                                        // console.log("actionurl",actionurl);
                                        // $(data).append(htmll);
                                        console.log("data",$("#PasswordResetform"));
                                        $( "body" ).text(  $("#PasswordResetform") );
                                    },error: function(result) {
                                        console.log('error');
                                    }
                                });  
                            });

这是控制对话框的集团:

/**
         * @function
         * @description
         */
        setDialogify : function (e) {
            e.preventDefault();
            var actionSource = $(this),dlgaction = $(actionSource).data("dlg-action") || {},// url,target,isForm
                dlgOptions = $.extend({},app.dialog.settings,$(actionSource).data("dlg-options") || {}),dlgBgOpacity = $(actionSource).data("bgcolor") || "undefined";

            dlgOptions.title = dlgOptions.title || $(actionSource).attr("title") || "";

            var url = dlgaction.url // url from data
                      || (dlgaction.isForm ? $(actionSource).closest("form").attr("action") : null) // or url from form action if isForm=true
                      || $(actionSource).attr("href"); // or url from href

            if (!url) { return; }

            var form = jQuery(this).parents('form');
            var method = form.attr("method")||"POST";

            // if this is a content link,update url from Page-Show to Page-Include
            if ($(this).hasClass("attributecontentlink")) {
                var uri = app.util.geturi(url);
                url = app.urls.pageInclude+uri.query;
            }
            if (method && method.toUpperCase() == "POST")
            {
                 var postData = form.serialize() + "&"+ jQuery(this).attr("name") + "=submit";
            }
            else
            {
                 if (url.indexOf('?') == -1 )
                 {
                  url+='?';
                 }
                 else
                 {
                  url += '&'
                 }
                 url += form.serialize();
                 url = app.util.appendParamToURL(url,jQuery(this).attr('name'),"submit");
            }

            var dlg = app.dialog.create({target:dlgaction.target,options : dlgOptions});

            app.ajax.load({
                url:$(actionSource).attr("href") || $(actionSource).closest("form").attr("action"),target:dlg,callback: function () {
                    dlg.dialog("open"); // open after load to ensure dialog is centered
                    // app.validator.init(); // re-init validator
                    // // Pre-enter the email into the forgotten password input interface
                    // if($(actionSource).attr("resetpassword")=='1'){
                    //  var resetemail = $("#dwfrm_login .login-email input.email-input").val();
                    //  $('#dwfrm_requestpassword_email').val(resetemail);
                    // }
                    $(".ui-widget-overlay").on("click",function() {
                        dlg.dialog("close");
                    });
                    if($(".popin-reinsurance").length > 0 && dlgBgOpacity != "undefined") {
                        var position = $(".popin-reinsurance").attr("style");
                        $(".popin-reinsurance").attr("style",position + dlgBgOpacity);
                    }

                    //Init Lookbook actions for shop the look in Product Detail Page (popin_shopthelook)
                    if($('.popinshoptheLook').length) {
                        Claudie.lookbook.bindEvents();
                    }

                    //init slide in popin lookbook
                    if($(".popinLookbook").length > 0 && window.innerWidth < 768){

                        var indexLkSlide;
                        var maxIndex = $('.swiper-container-lookbook .swiper-wrapper .swiper-slide').length;

                        var mySwiperLK = new Swiper('.swiper-container-lookbook',{
                            slidesPerView: 1,calculateHeight:true,spaceBetween: 5,onInit: function() {
                                indexLkSlide = mySwiperLK.activeIndex;
                                indexLkSlide = indexLkSlide + 1;
                                if(maxIndex == 1){
                                    $(".swiper-container-lookbook .slide-next").addClass("hidden");
                                }
                            },onSlideChangeStart: function() {
                                $(".lk-valid-add-cart,.lk-valid-error-cart").addClass("hidden");

                                indexLkSlide = mySwiperLK.activeIndex;
                                indexLkSlide = indexLkSlide + 1;
                                if(indexLkSlide < maxIndex){
                                    $(".swiper-container-lookbook .slide-next").removeclass("hidden");
                                } else {
                                    $(".swiper-container-lookbook .slide-next").addClass("hidden");
                                }
                                if(indexLkSlide > 1){
                                    $(".swiper-container-lookbook .slide-prev").removeclass("hidden");
                                } else {
                                    $(".swiper-container-lookbook .slide-prev").addClass("hidden");
                                }
                            }
                        });

                        $('.swiper-container-lookbook .slide-next').on('click',function(event){
                            event.preventDefault();
                            mySwiperLK.swipeNext();
                        });
                        $('.swiper-container-lookbook .slide-prev').on('click',function(event){
                            event.preventDefault();
                            mySwiperLK.swipePrev();
                         });
                    }

                    if($(".popinLookbook").length > 0){
                        $(".popinLookbook .swatches.size li").removeclass("selected");

                        var getWidthDialog = $('.popinLookbook').outerWidth(),getHeightDialog = $('.popinLookbook').outerHeight();
                    }

                },data : !$(actionSource).attr("href") ? postData : null
            });

        },

这是我的表格:

<form action="${URLUtils.continueURL()}"  method="post"   id="PasswordResetform" name="${pdict.CurrentForms.requestpassword.htmlName}">
        <div class="clearfix"></div>
        <fieldset>  
            <isif condition="${pdict.ErrorCode}">
                <span class="error-message" style="display: inline;">${Resource.msg('passwordresetfail.message','account',null)}</span>
            <iselse>
                <isif condition="${typeof(pdict.CustomerDoesnotExist) != 'undefined' && pdict.CustomerDoesnotExist == true}">
                    <span class="error-message" style="display: inline;">${Resource.msg('passwordreset.unknownemail',null)}</span>
                </isif>
            </isif>
            <isinputfield formfield="${pdict.CurrentForms.requestpassword.email}" type="email" requiredtext="${Resource.msg('forms.profile.email.error','forms',null)}"/>           
            <input type="hidden" value="true" name="ajax"/>
            <button class="requestpassword-submit button-style blue-button" type="submit" value="${Resource.msg('passwordreset.button',null)}" 
                        name="${pdict.CurrentForms.requestpassword.send.htmlName}"   >
                    ${Resource.msg('passwordreset.button',null)}
            </button>

            <input type="hidden" name="${pdict.CurrentForms.requestpassword.secureKeyHtmlName}" value="${pdict.CurrentForms.requestpassword.secureKeyValue}"/>


        </fieldset>

    </form>

最后,这是指形式动作的块,我想将其附加到我的身体上:

<isif condition="${pdict.CurrentHttpParameterMap.ajax.stringValue == 'true' || pdict.CurrentHttpParameterMap.format.stringValue == 'ajax'}">
    <isset name="DecoratorName" value="${'util/pt_empty'}" scope="page" />
<iselse>
    <isset name="DecoratorName" value="${'account/pt_account_login'}" scope="page" />
</isif>

<isdecorate template="${DecoratorName}">

<isinclude template="util/modules"/>

<div class="resetPasswordConfirm">
    <h1>${Resource.msg('passwordresetconfirm.title',null)}</h1>

    <p><isprint value="${Resource.msg('passwordresetconfirm.message',null)}" encoding="off" /></p>

    <iscomment>
        <p><a href="${URLUtils.httpsHome()}">${Resource.msg('passwordresetconfirm.homepagelink',null)}</a></p>
    </iscomment>
</div>
</isdecorate>

谢谢

wz5529885 回答:获取与表单操作有关的部分

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3111259.html

大家都在问