Openbravo Issue Tracking System - Retail Modules
View Issue Details
0036445Retail ModulesWeb POSpublic2017-07-07 11:372017-07-13 10:53
malsasua 
ranjith_qualiantech_com 
normalmajoralways
closedfixed 
5
 
 
migueldejuana
No
0036445: many listeners are being created for change event in scrollable table when lines are not added in the last position
When orderlines are created and they are inserted not in the last position (because a customization)[attached], then the method _createComponentForModel of ScrollableComponent component is creating listeners for events change and updateview many times for lines which already have it.
see attachment
Option 1 (preferred)

Test it carefully!! Create a static function. Maybe backbone will detect that your "on" is against a function which is already being used as a listener, so it will not create the listener

    this.func_checkAll = function (col) {
      //if the same collection is used by different components and one of them has been destroyed, the event is ignored
      if (this.destroyed) {
        if (this.collection) {
          this.collection.off('checkAll', this.func_checkAll);
        }
        return true;
      }
      this.collection.each(function (model) {
        model.trigger('check');
      });
    };
    this.collection.on('checkAll', this.func_checkAll, this);

Option 2

When creating listerners, first check if a model is already connected to a listener function. If it is, remove the listener (off) and then create again the listener (on).

example:
    if (!this.func_focus) {
      this.func_focus = function () {
        //stuff
      };
    }
    this.task.off('focusCalculated', this.func_focus);
    this.task.on('focusCalculated', this.func_focus);
    //end workaround
No tags attached.
txt hookPerformanceProblem.txt (401) 2017-07-07 11:37
https://issues.openbravo.com/file_download.php?file_id=10898&type=bug
Issue History
2017-07-07 11:37malsasuaNew Issue
2017-07-07 11:37malsasuaAssigned To => Retail
2017-07-07 11:37malsasuaFile Added: hookPerformanceProblem.txt
2017-07-07 11:37malsasuaResolution time => 1501192800
2017-07-07 11:37malsasuaTriggers an Emergency Pack => No
2017-07-07 11:42PracticsIssue Monitored: Practics
2017-07-10 15:49jmonfortIssue Monitored: jmonfort
2017-07-12 14:17ranjith_qualiantech_comAssigned ToRetail => ranjith_qualiantech_com
2017-07-12 14:17ranjith_qualiantech_comStatusnew => scheduled
2017-07-13 08:13hgbotCheckin
2017-07-13 08:13hgbotNote Added: 0098055
2017-07-13 08:13hgbotStatusscheduled => resolved
2017-07-13 08:13hgbotResolutionopen => fixed
2017-07-13 08:13hgbotFixed in SCM revision => http://code.openbravo.com/erp/pmods/org.openbravo.mobile.core/rev/cb08b24b56b58ef9c9998840d4e302041f31b42a [^]
2017-07-13 10:53migueldejuanaReview Assigned To => migueldejuana
2017-07-13 10:53migueldejuanaNote Added: 0098061
2017-07-13 10:53migueldejuanaStatusresolved => closed

Notes
(0098055)
hgbot   
2017-07-13 08:13   
Repository: erp/pmods/org.openbravo.mobile.core
Changeset: cb08b24b56b58ef9c9998840d4e302041f31b42a
Author: Ranjith S R <ranjith <at> qualiantech.com>
Date: Thu Jul 13 11:42:37 2017 +0530
URL: http://code.openbravo.com/erp/pmods/org.openbravo.mobile.core/rev/cb08b24b56b58ef9c9998840d4e302041f31b42a [^]

Fixed issue 36445 : Validate duplicate listeners in OB Scrollable Table

* In OBScrollable table, duplicate listeners should be avoided when component is created multiple times for same model

---
M web/org.openbravo.mobile.core/source/component/ob-scrollabletable.js
---
(0098061)
migueldejuana   
2017-07-13 10:53   
Tested and reviewed