EasyUI Forum

General Category => Bug Report => Topic started by: eser on October 05, 2014, 11:17:00 PM



Title: dialog onLoadError event does not fire
Post by: eser 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?



Title: Re: dialog onLoadError event does not fire
Post by: jarry 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);
}
});
}
})