This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Remove grp.listener
#1
Hi,

I´m doing a widget with dynamic object address and I need to remove listeners when I close widget or when I open it again with another address.

Code:
  // Declare vars   var ObjEscucha = "0/0/0";   var MainObjectSplitted = [];   var DirOriginales = ["8/1/102","8/1/103"];   var DirWrNuevas = ["1/1/1","1/1/2"];   var DirWrSustituidas = []   var DirEstadosReales = [["0/2/0","0/2/1"],["0/3/1","0/3/2"]]   var DirEstSustituidas = [["Es la 0/2/0","Es la 0/2/1"],["H","ADIOS"]]     function actualizarEstados(a,b) {     return function (obj) {       console.log(DirEstSustituidas[a][b])     };   }     function removelistener(src) {    var el = $(src) // source element reference      , addr = el.data('status-object') // group address of status object      , id = Scada.encodeGroupAddress(addr) // address to id      , obj = objectStore.objects[ id ]; // get object's store reference     if (obj) {      // find listener that is attached to the source element     console.log(addr)      $.each(obj.listeners, function(index, listener) {        // remove the listener        if (listener.bind.el && el.is(listener.bind.el)) {          obj.listeners.splice(index, 1);        }      });    }   }     // Detect adresses linked to widget button and create arrays   $(".screen_widget").on("click", function(e) {     ObjEscucha = $(this).data("object");         for (var i = 0; i < DirOriginales.length; i++) {                 if (ObjEscucha == DirOriginales[i]){                    DirWrSustituidas = DirWrNuevas[i]                                     //I NEED TO REMOVE THIS LISTENER WHEN I OPEN AGAIN THE WIDGET                   for (var j = 0; j < DirEstadosReales[i].length; j++) {                     grp.listen(DirEstadosReales[i][j], actualizarEstados(i,j));                   }                 }         }      });    

How can i do that?

Thanks!
Reply


Messages In This Thread
Remove grp.listener - by DGrandes - 07.03.2023, 10:34
RE: Remove grp.listener - by admin - 07.03.2023, 10:57
RE: Remove grp.listener - by DGrandes - 07.03.2023, 11:38
RE: Remove grp.listener - by admin - 07.03.2023, 11:40
RE: Remove grp.listener - by DGrandes - 07.03.2023, 11:52
RE: Remove grp.listener - by admin - 07.03.2023, 12:03
RE: Remove grp.listener - by DGrandes - 07.03.2023, 12:10

Forum Jump: