JavaScript JavaScript multiple intervals and clearInterval javascript multiple intervals,js multiple intervals,javascript multiple set intervals,

I have a small program, when you click on an "entry", the editing mode is opened, and the entry is to edit locked for others. There is every 10 seconds sends an ajax request to update the timestamp in the table.

$(".entry-edit").click(function() {
  // code

  loopLockingVar = setInterval(function() { loopLockingFunction(id) }, 10000);

  // code
});

Then I have a cancel button to updating the timestamp in the table to 0 and to clear the interval.

$(".entry-cancel").click(function() {
  // code   

  clearInterval(loopLockingVar);

  // code
});

It all works when editing only one entry, but if two or more processed simultaneously, and then click cancel, the interval for the first entry still further...

I have this tried:

var loopLockingVar;
$(".entry-edit").click(function() {
  // code

  if( ! loopLockingVar) {
    loopLockingVar = setInterval(function() { loopLockingFunction(id) }, 10000);
  }

  // code
});

However, this does not work more if you cancel and again clicks on edit...

Answer:1

I have been reading about revealing module pattern in Addy Osmani's book. It highlights following disadvantage: A disadvantage of this pattern is that if a private function refers to a public ...

I have been reading about revealing module pattern in Addy Osmani's book. It highlights following disadvantage: A disadvantage of this pattern is that if a private function refers to a public ...

  1. javascript revealing module pattern
  2. javascript revealing module pattern constructor
  3. javascript revealing module pattern with parameters
  4. javascript revealing module
  5. javascript revealing module pattern multiple instances
  6. javascript revealing module pattern es6
  7. javascript revealing module pattern vs prototype
  8. javascript revealing module pattern inheritance
  9. javascript revealing module pattern nested namespace
  10. javascript revealing module pattern events
  11. javascript revealing module pattern tutorial
  12. javascript revealing module pattern public variables
  13. js revealing module pattern
  14. javascript self revealing module pattern
  15. node js revealing module pattern
  16. javascript module vs revealing module

I have following html form: <form method="POST" action="uploadImage" enctype="multipart/form-data"> <input type="file" class="file" name="file"/> ...

I have following html form: <form method="POST" action="uploadImage" enctype="multipart/form-data"> <input type="file" class="file" name="file"/> ...

I am developing an app using jQuery Mobile with PHP. I am not using Phonegap or other frameworks. I need to find user's geolocation. If user device's GPS is off, then I cant get a location. now I need ...

I am developing an app using jQuery Mobile with PHP. I am not using Phonegap or other frameworks. I need to find user's geolocation. If user device's GPS is off, then I cant get a location. now I need ...

  1. check device user agent
  2. php check user device
  3. check point user device management
  4. check user agent mobile device

I have a very simple module that I am bundling with Browserify. I want to use that bundle both in the browser as well as in node. In node, it works just fine if I require the non-bundled module; ...

I have a very simple module that I am bundling with Browserify. I want to use that bundle both in the browser as well as in node. In node, it works just fine if I require the non-bundled module; ...

  1. require returns empty object
  2. node require returns empty object
  3. nodejs require returns empty object
  4. webpack require returns empty object
  5. require('fs') returns empty object
  6. javascript require returns empty object
  7. browserify require returns empty object
  8. require module returns empty object