EasyUI Forum
April 25, 2024, 01:14:13 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: How to bind Form Submit Function to the Content from Window Refresh (new URL)?  (Read 4428 times)
poeziafree
Jr. Member
**
Posts: 69


View Profile Email
« on: December 03, 2021, 11:59:10 PM »

Hello,

I am stuck... Any help will be much appreciated.

After the user submits the form which is located in Window, there is refresh function from a new URL:

$('#windowPopUp').window('refresh', '/saoperatoro/editUser.php?id='+data.user);


the refresh URL loads new form. My question is how to add $('#...').form('submit', {... to the form that was loaded after refreshing the window?

Here is the full code:

Code:
function CreateOperator(){
       
        $.messager.progress({ title: 'მიმდინარეობს მონაცემების შენახვა', msg: 'გთხოვთ, დაელოდოთ...' });
$('#CreateOperator').form('submit', {
url: '/api-submitCreateOperator',
onSubmit: function(){
var isValid = $(this).form('validate');
if (!isValid){
$.messager.progress('close'); // hide progress bar while the form is invalid
}
return isValid; // return false will stop the form submission
},
success: function(data){
$.messager.progress('close'); // hide progress bar while submit successfully

        var data = eval('(' + data + ')');  // change the JSON string to javascript object
        if (data.success){
           
            //$('#windowPopUp').window('refresh', '/saoperatoro/editUser.php?id='+data.user);
           
            $('#windowPopUp').window({
                                title: 'მომხმარებლის რედაქტირება',
                                width: '80%',
                                height: 600,
                                modal: true,
                                resizable: true,
                                closeAnimation: 'hide',
                                minimize: 'animate',
                                collapsible: false,
                                href: '/saoperatoro/editUser.php?id='+data.user,
                                footer: '#windowPopUpFooter',
                                onBeforeLoad: function() {
                                    $(this).window('hideFooter');
                                    $.messager.alert('წარმატებით შესრულდა',data.message);
                                },
                                onLoad: function() {
                                    $(this).window('showFooter');
                                    $(this).window('footer').html('<a href="#" class="easyui-linkbutton" iconCls="icon-ok" style="width:80%;height:32px">Register</a> <a href="#" class="easyui-linkbutton" iconCls="icon-ok" style="width:20%;height:32px">Cancel</a>');
                                    $(this).window('footer').css('padding', '5px');
                                   


                                },
                                onMinimize: function() {



                                    var contents = $('#windowPopUp').contents();

                                    var id = 'create-operator';
                                    var title = '<uniqueID>' + id + '<\/uniqueID> მომხმარებლის შექმნა';


                                    var tabPanel = $('#wu-tabs');
                                    if (tabPanel.tabs('exists', title)) {
                                        tabPanel.tabs('select', title);
                                        return false;
                                    }


                                    tabPanel.tabs('add', {
                                        id: id,
                                        title: title,
                                        content: contents,
                                        fit: true,
                                        cls: 'pd3',
                                        closable: true
                                    });




                                }
                            });
           
           
           
           
            $('#operatorsIndex').datagrid('reload');
        }
        if (data.error){
            $.messager.alert('შეცდომა',data.message,'error');
        }
 
}
});
       
       
        }
Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #1 on: December 06, 2021, 02:03:49 AM »

If you want to submit a form in the window, just to find the form and call the 'submit' method.
Code:
$('#windowPopUp').find('form').form('submit', {
//...
})
Logged
poeziafree
Jr. Member
**
Posts: 69


View Profile Email
« Reply #2 on: December 07, 2021, 10:17:40 AM »

Hi Jerry,

Thank you for your reply.

Is there any method to run the function after the refresh is done?

For example: $('#windowPopUp').window('refresh', '/saoperatoro/editUser.php?id='+data.user);

I need to detect when refresh is finished and then run the function...
Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #3 on: December 07, 2021, 11:05:16 PM »

Please listen to the 'onLoad' event which will be triggered when calling the 'refresh' method to load the remote content.
Code:
$('#windowPopUp').window({
onLoad: function(){
//...
}
})
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!