Page 1 of 1

jQuery event-aliases deprecated since jQuery 1.8.

Posted: Tue Nov 29, 2022 8:20 pm
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