Announcement

Collapse
No announcement yet.

This.model.save not for only one entity?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • This.model.save not for only one entity?

    Hello!!! I created buttons that change the status of the Case entity. Most of the code is in the detail.js file in the directory ..... / client / modules / casebuttons / src / views / case. Changing the status produces the following code:
    PHP Code:
    this.model.save({
          
    statusparam
    }).success(function () {
          
    this.notify(false);
          
    this.model.trigger('after:save');
    }.
    bind(this)); 
    Everything works well, but sometimes even too (very rarely): I change the status in one “Case” - the status changes to identical in a few more “Case”, which have nothing to do with the first. How to get rid of this error? There is a suspicion that this is somehow connected with this.model.collection.

  • #2
    Found a mistake: during a quick transition between entities, ajax worked asynchronously, which led to incorrect button generation. Set the async parameter: "false", and everything works as it should.

    Comment


    • #3
      yuri , please take a look on this. A button that doesn't need to click on EDIT first, to be clicked, would be a great feature.

      Thanks.

      Comment


      • #4
        async: false is not recommended and I wonder if it's still available in browsers. Was deprecated long ago.

        You need to review your logic. This behavior definitely should not't be happening.

        Comment


        • #5
          In another way, the problem returns. The buttons are located in clienDefs, actions for them are specified in view / detail.js (JS code from the first message). If you quickly and heavily press the transition buttons (see picture), or use the browser buttons forward, backward, then after clicking the created buttons, more than 1 entity is edited. How to prevent this?Click image for larger version

Name:	111.png
Views:	563
Size:	52.3 KB
ID:	52016

          Comment


          • #6
            Can you provide whole js file contents?

            Comment


            • #7
              If you listen to 'change:status' and then save a model -- it's a wrong way.

              Comment


              • #8

                After quickly switching between entities, the code is: console.log (this.model); displays 2-4 entities. That is how it should be? How to avoid this error?
                I added the following code to "action follow": console.log (this.model.id); then i repeated the above steps and after pressing the "follow" button received:Click image for larger version

Name:	1.png
Views:	537
Size:	36.9 KB
ID:	52156
                A rare mistake, but our managers are faced with this, maybe there are still some conditions for receiving this error.

                Last edited by Kirill; 10-03-2019, 06:18 AM.

                Comment


                • #9
                  I'm still waiting your answer or reaction....

                  Comment


                  • #10
                    I will look into. I need to reproduce first.

                    Comment


                    • #11
                      This fix may solve the problem: https://github.com/espocrm/espocrm/c...09bfa8bd8b6fdf

                      Comment


                      • #12
                        Thank you, this fix partially solved my problem. There are new problems. How to call actionEdit using code without using: $ ('[data-action = "edit"]').сlick (); ? this.setEditMode(); not working now. How to get the mode of the current model in detail?
                        Last edited by Kirill; 10-09-2019, 10:11 AM.

                        Comment

                        Working...
                        X