Получить раздел, относящийся к действию формы

На самом деле, когда я нажимаю кнопку отправки, элемент отображается в диалоговом окне 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','account',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','account',null)}" 
                        name="${pdict.CurrentForms.requestpassword.send.htmlName}"   >
                    ${Resource.msg('passwordreset.button','account',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','account',null)}</h1>

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

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

Спасибо

0 ответов

Другие вопросы по тегам