jQuery event-aliases deprecated since jQuery 1.8.

Using Javascript from SpiderBasic
Dirk Geppert
Posts: 249
Joined: Fri Sep 22, 2017 7:02 am

jQuery event-aliases deprecated since jQuery 1.8.

Post by Dirk Geppert »

I use the webgadget in a project to display html that is edited in an editor.

Since the function SetGadgetItemText(Gadget, #PB_Web_HtmlCode, Html) unfortunately does not work correctly, I use a Javascript code (credits to Peter).

Since this code suddenly caused a problem, I now found out that jQuery has changed something:

; jQuery event-aliases like .load(), .unload() Or .error() that all are deprecated since jQuery 1.8. Lookup For these aliases in your code And replace them With the .on() method instead. For example, replace the following deprecated excerpt:
; $(window).load(function(){...});
; With the following:
; $(window).on('load', function(){ ...});

If anybody else use this code SetWebGadgetHtml() this is the fix:

Code: Select all

Procedure SetWebGadgetHtml(Gadget, Html.s)
  
;   SetGadgetItemText(Gadget, #PB_Web_HtmlCode, Html)
;   ProcedureReturn 
  
  If GadgetType(Gadget)=#PB_GadgetType_Web
    ! var iframe = $(spider_GadgetID(v_gadget).div).find("iframe");
    ! iframe.contents().find("html").html(v_html);
    ! $(iframe).on('load', function(e) {
    !   iframe.contents().find("html").html(v_html);
    ! });
  EndIf

EndProcedure