jquery-events

On CTRL+MOUSEWHEEL event

拥有回忆 提交于 2020-01-02 07:03:35
问题 I was asked to implement ctrl+mousewheel event for our page site in order to change image offset on user zoom in or zoom out. I found this old answer Override browsers CTRL+(WHEEL)SCROLL with javascript and I`ve tried to do the same. I downloaded the jQuery Mouse Wheel Plugin for the implementation and here is my code: var isCtrl = false; $(document).on('keydown keyup', function(e) { if (e.which === 17) { isCtrl = e.type === 'keydown' ? true : false; } }).on('mousewheel', function(e, delta) {

Cross-browser handling the “Enter” key pressing using Javascript

拥有回忆 提交于 2019-12-31 03:59:05
问题 I have got the following sample, that easily detects the "Enter" key pressing and handles it correctly. Here it is: <!DOCTYPE html> <html> <head> <title>keyCode example</title> <script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function () { $("#search-input").keyup(function (event) { event = event || window.event; if (event.keyCode == 13 || event.which == 13) { $("#search-button").click(); } }); $("

Listen for jQuery Event With Vanilla JS

泪湿孤枕 提交于 2019-12-30 18:26:16
问题 So I am trying to determine whether its possible to listen for events added with jQuery using vanilla JS. I found this question: Listen to jQuery event without jQuery which definitely answers it for version 1 of jQuery. How about version 3 however? I have a fiddle that I have put together to test out, but I am unable to get the 1st submit to work with any version of jQuery. Am I missing something, or is the event model in jQuery 3 still not using the DOM event model? https://jsfiddle.net

Is there an opposite function of preventDefault() in JavaScript?

ε祈祈猫儿з 提交于 2019-12-30 05:38:08
问题 I am counting words in a text field and after a certain amount of words, I use prevent default. In the else, I would like to re-enable the default commands. Does preventDefault( ) have an opposite function? Here is some sample code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>preventDefault</title> <style type="text/css"></style> <script type="text/javascript

Turn the Tooltip Bootstrap functionality off

只谈情不闲聊 提交于 2019-12-29 18:18:28
问题 According the documentation is is possible to turn off the functionality just doing $('body').off('.alert.data-api') . In the case of tooltip I tried the following from js console $('body').off('.tooltip.data-api') but it does not disable the tooltip on bottons. Any hints how to precede? 回答1: You can't disable tooltips that way because it has no event listener on the body. Instead, you can disable the tooltips themselves using the code below. $('[rel=tooltip]').tooltip() // Init tooltips $('

Jquery making Rateit (star) plugin work for added elements

半世苍凉 提交于 2019-12-25 06:57:12
问题 I have some rating code: $('div.rateit').rateit(); I want it also to function for added elements. Here is the plugin: http://rateit.codeplex.com/ 回答1: Seems you might need to use jQuery on() method, like this: $('div.rateit').on('event which triggers the rateit()', rateit); 回答2: It works! : If you have a look at the source of the rateit plugin (src/jquery.rateit.js) you'll see that at the end of file appears the invocation: //invoke it on all .rateit elements. This could be removed if not

CKEditor 'save' is different than submit

我与影子孤独终老i 提交于 2019-12-25 04:13:18
问题 I use this, to submit the form if you hit ctrl+enter: $(function() { CKEDITOR.on('instanceReady', function(evt) { evt.editor.setKeystroke(CKEDITOR.CTRL + 13, 'save'); }) }) Unfortunately this seems to be a bit different to pressing the submit button. If I hit ctrl+enter I get a popup with a warning that there is changed data in the form, and that this data would get lost. If I choose "leave the page", then everything works fine (not data gets lost). How can I make ctrl+enter work like

Jquery hovercard

丶灬走出姿态 提交于 2019-12-23 20:13:50
问题 I'm using http://designwithpc.com/Plugins/Hovercard , but I can't find out how to declare a var on hovercard. Every job-desc has his own ID and it should be call when hovering labels. I hope I explained well. <li id="577" class="item"> <span> <h3 class="padding-left"><label class="labeldesc" for="">Text</label></h3> </span> <span class="job-descr" id="hiden-577">TextTextTextTextText</span> </li> <li id="588" class="item"> <span> <h3 class="padding-left"><label class="labeldesc" for="">Text2<

How can I prevent a page unload with jQuery?

南楼画角 提交于 2019-12-23 14:59:05
问题 In my program, if a user tries to leave a page, he'll receive a dialog box asking if he is sure he wants to leave. How should I implement the 'cancel' option if the user chooses not to leave the page? Source javascript code: $(window).unload(function(){ var c= confirm ("Are you sure?"); if (c){ alert("Thanks. Good luck!"); } else{ ???? } }); 回答1: window.onbeforeunload = function() { return 'You have unsaved changes!'; } many question about this in stackoverflow How can I override the

How to use tilesloaded event for google maps v3

风格不统一 提交于 2019-12-23 13:06:55
问题 Here I have a code: <script> $(function() { $( "#photo" ).resizable(); $( "#photo" ).draggable({revert: 'invalid'}); $( "#left" ).droppable({ accept: '#photo', drop: function( event, ui ) { $( this ) .find( "p" ) .html( "Dropped!" ); } }); }); </script> and this code I must run after full loading google maps, so I need to "hook up" tilesloaded event for this code. http://jsbin.com/ayugun/7/edit But how to do that? 回答1: Here is the code google.maps.event.addListener(map, 'tilesloaded',