logo
down
shadow

how to avoid multiple call from mouse up


how to avoid multiple call from mouse up

By : Syedur Rahaman
Date : November 18 2020, 03:49 PM
I wish did fix the issue. Your issue seems to be with trying to add an event listener inside your function every time there is a mouseup event. Try setting up that.saveTextButton.click(function () separately and just showing the button on mouseup. I had to fiddle with it a little not having all the vars your code needs but you should get the idea:
code :
var valid =true;
//var valid =false;

$('.documentpage').mouseup(function(e){
                e.stopPropagation();
                if($.trim(window.getSelection().toString()).length) {
                    setTimeout(function () {
                    //delaying to get selection
                      
                      //..other code that checks stuff...
                      
                      if(valid){ 
                           $('#saveTextButton').show();

                      }                      
                    }, 100);
                } 
});


$('#saveTextButton').click(function(){
  
      alert('function called');
  
});
.documentpage{
 height:100px;
  width:1000px;
  background-color:#cccccc;
  }

#saveTextButton{
  display:none;
  }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="documentpage">this is some test text</div>
<input type="button" id="saveTextButton" value="Push me"></input>


Share : facebook icon twitter icon
javascript avoid multiple call

javascript avoid multiple call


By : jhancock
Date : March 29 2020, 07:55 AM
this one helps. I think the most sensible way to handle that is to disable the link once it is clicked, and then reenable it when the function is done running. Assuming you have jQuery available, something like...
code :
$('#button').click(function () {
  $(this).attr("disabled", "true");
  doTheFunction();
  $(this).attr("disabled", "false");
});
$('#button').click(function () {
  $(this).attr("disabled", "true");
  doTheFunction();
  var btn = $(this);
  setTimeout(function () {
    btn.attr("disabled", "false");
  }, 5000);  // reenable the button 5 seconds later
});
$('#link').click(function () {
  if ($(this).hasClass('disabled_link')) {
    return;
  }
  $(this).addClass("disabled_link");
  doTheFunction();
  var link = $(this);
  setTimeout(function () {
    link.removeClass("disabled_link");
  }, 5000);  // reenable the button 5 seconds later
});
How to avoid if statement and call multiple constructors

How to avoid if statement and call multiple constructors


By : urmnjuriyam
Date : March 29 2020, 07:55 AM
wish help you to fix your issue How about using builder pattern here? See this link from Javacodegeeks for code example
code :
QueryProducer.withQuery(yourQuery).withA(a).withB(b).build();
How to avoid multiple function call

How to avoid multiple function call


By : panteon00
Date : March 29 2020, 07:55 AM
it fixes the issue Use delegation, then there is no need to attach the event handler function every time you append. Remove your getId() function and replace it with a delegated on() method:
code :
var id = 1;

$('#create').on('click', function () {
    id++;
    $('.players').append('<a href="#" class="new" data-id=' + id + '> ' + id + 'player</a>');
});

$('.players').on('click', '.new', function(e) {
    e.preventDefault();
    var id = $(this).data('id')
    alert(id);
});
Avoid multiple if clauses to call different methods

Avoid multiple if clauses to call different methods


By : ahmed magdy
Date : March 29 2020, 07:55 AM
I wish this helpful for you Functions are first-class objects in Swift, which mean you can pass them like variables too. Instead of building the function name dynamically, associate them with the UITextField in a tuple.
Assuming you have these functions:
code :
func check (firstName: String) -> Bool {
    // ...
}

func check (lastName: String) -> Bool {
    // ....
}
// checks is an array of tuples. Each tuple has 2 components:
// a UITextField and a function which takes a String and return a Bool
let checks: [(field: UITextField, checker: (String) -> Bool)] = [
    (firstNameField, check(firstName:)),
    (lastNameField , check(lastName:))
]

for c in checks {
    guard c.checker(c.field.text!) else {
        c.field.text = "foo"
        return false
    }

    c.field.text = "bar"
}
React : How to avoid multiple function call

React : How to avoid multiple function call


By : cebucu
Date : March 29 2020, 07:55 AM
I wish this help you State is not updating at time when urlParams is being called. As @jolly told you setState is Asynch function so it's better to use it in a callback or you may simply pass your sortedData type as in argument in getSortedType function instead of updating state. Also, ReactJS community suggests or the best practice is to use state only if props are needed to be updated.
In case, if you dont feel comfortable with CB. you may use setTimeOut which I think is a bad practice but it would solve your problem. your code would be like:
code :
getSortedData=()=>{
    this.setState({sortedData:'name desc'});
    setTimeout(() => {
      this.getData();
    }, 200);
}
Related Posts Related Posts :
  • RangeError: Maximum call stack size exceeded with array.slice
  • node rest client get with local variable
  • If condition not executes while mouse move fastly
  • Count the number of displayed elements in a HTML list
  • Locate JavaScript source code in Emacs
  • Clean, Modular Code vs MV* Frameworks
  • infinite scroll without loading image
  • Backbone: reverse collection order with comparator
  • What do printers ignore?
  • jQuery UI .tabs() Contentless tab?
  • Execute Javascript alert() after page (visually) loaded
  • JavaScript - duplicating array doesn't work
  • Excessive clickable area below image
  • JavaScript Regex: Replace |b| with <b>
  • Unexpected value change in 2D array in JavaScript
  • Function doesnt see parameter as a array of objects
  • jQuery fetch keypress event on chrome and IE
  • How to enable jquery validate localization?
  • Cassandra map collection returned by node.js Helenus looks odd
  • angular ng-repeat with multiple filter options
  • Selecting Children without ID or Class names
  • How to uncheck a group of checkboxes when another checkbox is checked
  • Is hiding content by Javascript or jQuery Worth trying
  • Load XUL resource using javascript
  • XML to HTML text area from server file system
  • set focus() on textbox on form onload
  • es lint '' is assigned a value but never used' eventhough i have used it
  • Can "name" attribute be used for custom VueJS components
  • Get innerHTML of content when it is clicked
  • HTTPS causes CSS animations to not load? Very confused
  • How to hide other div apart from touched div to the band
  • Is global variable assignment atomic on NodeJS?
  • Datepicker onchangemonthyear beforeshowday
  • trying to render html files using jade but it still adresses it as a jade
  • Google Analytics - Understanding and Dissecting the Snippet: What is | | [ ];
  • Replacing "[aA09.b]." to "[aA09.b]\n" in in JavaScript
  • Why wrap a function definition in an immediate function?
  • Enable / disable jQuery script on switching to different tab in a HTML page
  • how can find return variable value outside anonymous function in node js mysql query function
  • Converting 1 to 0001 in javascript array
  • svg viewbox should not resize the text fontSize?
  • store newline character with string in a variable
  • MP4 videos in Flowplayer does not play in Windows 7 Chrome
  • jquery focusin event not firing
  • How to debug Vue application with google chrome
  • html 5 web app cache download complete javascript alert?
  • Ember.js setupController fired only once
  • How to validate a currency input
  • How to convert my Array of data to key & value pair
  • Statistics circles in CSS
  • So I wanted to make a trig solver in javascript?
  • Showing HighCharts series name on x-axis and in legend
  • In Rails, how can we pass parameters in script?
  • Build Fails: `npm rebuild node-sass --force`
  • Angular Datepicker change dateformat
  • Trying to extract data from between two sets of characters
  • Configuring Jest in WebStorm
  • Uncaught Error: Syntax error, unrecognized expression: tr.ec_portfolio_title,
  • JQuery fading in fading out continuously
  • Unexpected end of input (Line 1) and Undefined Function?
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org