EasyUI Forum
September 14, 2025, 04:07:31 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: dialog onLoadError event does not fire  (Read 9645 times)
eser
Newbie
*
Posts: 1


View Profile Email
« on: October 05, 2014, 11:17:00 PM »

Hi,
I want to use onLoadError event of dialog. I use easyui 1.4 with patch (26.09.2014).
I have the following code:

...
<tr style="vertical-align: top;">
        <td>Type of event:</td>
        <td><span><textarea id="eventTypeName" name="eventTypeName" class="easyui-validatebox" style="width: 600px"
                            validType="remote['${createLink(action:'validateEventType')}','eventTypeName']" delay="2000">${cmd?.eventTypeName}</textarea>
            <button onclick="getDictionary('Event types, '${createLink(controller:'dictKusp', action:'eventTypeTree')}', '#eventTypeName'); return false;">...</button></span></td>
    </tr>
...

<r:script>

    var selectResult,
        $dlg = $('#dlg'),

    function getDictionary(title, url, el) {
    $dlg.dialog({
        title: title,
        width: 500,
        height: 400,
        closed: false,
        cache: false,
        href: '${createLink(controller:'dictKusp', action:'selectFromTree')}?url=' + url,
        modal: true,
        buttons:[
        {text: 'Свернуть все',
        handler: function(){
            $('#tree').tree('collapseAll'); }
        },
        {text:'ОК',
        handler: function(){
            setResult(el); $dlg.dialog('close'); }
        },
        {text:'Закрыть',
        handler: function(){
            $dlg.dialog('close'); }
        }],
        onLoad: function() {
            console.log('onLoad');
        },
        onLoadError: function() {
            alert("onLoadError");
        }
    });
    };
...
</r:script>

I use easyui in grails 2.4.3. That's why there is <r:script>,
r - is namespace for "resouces" plugin in grails.
It can be replaced with simply <script> tags, if you does not use grails.
${createlink (controller: ...} is also grails tag.

When I click button on my form then dialog was opened and the tree in dialog was populated with data from the remote server.
I close the dialog.
Then I unplag network cable to drop connection with the remote server and click button again.
I suppose to see the alert dialog, but it does not appear.

onLoadError event does not fire.

But onLoad event fire and write "onLOad" to console.

Why onLOadError error does not fire?

Logged
jarry
Administrator
Hero Member
*****
Posts: 2298


View Profile Email
« Reply #1 on: October 06, 2014, 01:31:09 AM »

The 'onLoadError' event is the wrapper for 'error' callback function of $.ajax, which is called if the request fails. You can try to override the $.fn.dialog.defaults.loader function to fit your requirements.
Code:
$.extend($.fn.dialog.defaults, {
loader: function(param, success, error){
var opts = $(this).panel('options');
if (!opts.href){return false}
$.ajax({
type: opts.method,
url: opts.href,
cache: false,
data: param,
dataType: 'html',
success: function(data){
success(data);
},
error: function(){
error.apply(this, arguments);
}
});
}
})
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!