This is a migrated thread and some comments may be shown as answers.

Error Handling within an Editor and ImageBrowser

1 Answer 198 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Rodrigo
Top achievements
Rank 1
Rodrigo asked on 31 Aug 2015, 07:58 PM
Hello! I'm using the Editor with a button to display the ImageBrowser component.

My API will return a Bad Request status code whenever the image is too large or somehow invalid to be uploaded.

I wasn't able to customize the error message displayed. Also, even though the request returns with an error, the item is displayed within the Image Browser with the loading icon.

I checked and even on the demos this is happening.

How can I have the image browser to not display items when the request (to upload) return with an error and also customize how the error message is displayed? (ie, display the string content returned by the server without prepending content to the string as the default behavior).

Thanks for helping.

1 Answer, 1 is accepted

Sort by
0
Alexander Popov
Telerik team
answered on 03 Sep 2015, 06:37 AM
Hi Rodrigo,

You can try getting the ImageBrowser instance once the command is executed. This will allow you to access the Upload widget as well and subscribe to its error event. For example:  
$("#editor").kendoEditor({
  execute: function(e){
    if(e.name == "insertimage") {
      setTimeout(function() {
        var ib = $("[data-role='imagebrowser']").getKendoImageBrowser();
        ib.upload.bind("error", function() {
          alert("error uploading file");
        })
      })
    }
  },


Regards,
Alexander Popov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Editor
Asked by
Rodrigo
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Share this question
or