FAQ Database Discussion Community


using jQuery's delegated event on() within every turbolinks page:load

jquery,ruby-on-rails,ruby-on-rails-4,javascript-events,turbolinks
I had this code in my rails app: $(document).ready( function() { myCustomFunction("#link-selector"); } function myCustomFunction(linkCssSelector){ // some stuff... $(document).on('click', linkCssSelector, function(){ // ...some other stuff... }); } The click event handling is already delegated to the document, but now I have to add Turbolinks to my app. Then, I would...

Angular.js - emit periodic event to directive

javascript,angularjs,javascript-events,angularjs-directive,angularjs-scope
I have one directive, which translate dates&times to better - human reading - form, like "now", "one minute ago", .. I'd like to update it periodically so dates which are translated as "now" will be after one minute updated.. One way how to solve this to make $interval in directive...

Is there an event for onclick end?

javascript,jquery,html5,javascript-events,onclick
I have a code in which should only be executed after an onclick event. On mobile devices its fine because I use touchstart and touchend. Is there an event similar to touchend for use on a computer? My code currently looks similar to.. document.getElementById('trigger-box').addEventListener(function(e) { // the event will be...

Accessing 'this' table cells value

javascript,dom,javascript-events
I have a form, after form has been filled and add button pressed - all the values from the form get to PouchDB and then into the table in the browser. I need to make an "edit" option. The idea is: <td ondblclick='updateVaucher()' style='cursor: pointer'>"+data[i].doc.vaucherID+ "</td> Now the question is:...

AngularJS - Click event (in directive) triggers when anywhere in the parent is clicked

javascript,angularjs,javascript-events,angularjs-ng-transclude
I'm going to do my best to explain my issue - bear with me. This whole thing is a directive for file selection: The directive has an ng-transclude component that contains a few directives, contained in their own divs. Parent directive: <div class="extra-cells"> <div ng-transclude class="extra-cells-row"></div> </div> ng-transclude content: <div...

jQuery event.preventDefault() don't work unless debugging

javascript,jquery,events,javascript-events,event-handling
I am trying to use this approach in order to convert GET parameters to POST. I also want the anchor to be properly handled even if the middle mouse button is clicked. This is how I did the the event handlers binding: $(document).ready(function () { $(".post").each(function(){ $(this).mousedown(function(evt){ switch(evt.which){ case 1:...

How can get custom attribute value in meteor?

javascript,checkbox,meteor,javascript-events
How can get the value of "key" attribute which is checked??? Html Code: <input type="checkbox" class="each-tab-1" key="some1" value="456"> <input type="checkbox" class="each-tab-1" key="some1" value="789"> <input type="checkbox" class="each-tab-1" key="some2" value="890"> <input type="checkbox" class="each-tab-1" key="some2" value="901"> <input type="checkbox" class="each-tab-1" key="some1" value="012"> JS code: 'click .action' : function(event, template){ $("input[class^=each]:checked").each(function(){...

jQuery Custom Event not triggering in AJAX Success Callback

javascript,jquery,ajax,javascript-events
I am experimenting with jQuery custom Events in my Application. In the jQuery AJAX request code below, in the success callback I am trying to trigger() my custom Event It does not seem to be triggering it though. Will this simply not be able to be done in the success...

WebApp doesn't recognize that an input field was changed when set with jQuery in PhantomJS

javascript,jquery,javascript-events,phantomjs,html-input
I open telegram with PhantomJS and try to fill phone number input with evaluate page like below: page.evaluate(function(){ $("input[name='phone_number']").val("123456789"); }); When PhantomJS clicks on next button with jQuery the alert massage says "tel input is empty" but when the page is rendered we can see numbers in the input field....

Move a button created dynamically JavaScript

javascript,javascript-events
I am a very beginner! I've dynamically created a random number of buttons. After creation, I want them to automatically start moving. From some reason or another, my code creates the buttons, but doesn't make them move. Thanks a lot! javascript.js function myFunction() { for (i = 1; i<=Math.random() *...

Extjs5 - right click context menu with Ext.form.field.HtmlEditor

javascript,extjs,javascript-events,event-handling
Problem description I have prepared this index.html, which creates a simple Ext.form.field.HtmlEditor. I want to have a right-click-context-menu, which is capable of doing something with words that were marked by the user: <!DOCTYPE html> <html> <head> <script type="text/javascript" src="/ext-5.1.1/build/ext-all-debug.js"></script> <link id="theme1" rel="stylesheet" type="text/css" href="/ext-5.1.1/build/packages/ext-theme-neptune/build/resources/ext-theme-neptune-all.css"> <script...

How to reset the complete document after opening it?

javascript,pdf,javascript-events,reset,acrobat
i want to reset the complete form after opening it. I have tried this: page.open = this.resetForm(); But it doesn't work. Im using Acrobat Pro DC....

sublime-scroll plugin is not scrolling as expected (iframe event catching issue)

javascript,jquery,iframe,javascript-events
I want to read mouse position from an iframe. I am doing it with this implementation: $($("#sublime-scroll-iframe").contents()[0], window).find('body').bind("mousedown", function(e) { console.log("x:" + (e.pageX) + ", y:" + e.pageY); } ); My working example: http://jsfiddle.net/s37e1ro0/1/ but I can't make it to work with demux's sublime-scroll js script. Output is window coordinates...

Publisher in Pub/Sub should be Synchronous or Asynchronous?

javascript,design-patterns,javascript-events,anti-patterns
My view on mechanism: Pattern wise publisher should just publish an event and should not care about listeners / subscribers for that topic / event. In case of JavaScript, lot of frameworks for Pub / Sub publishes event in Sync manner for example : framework just maintains map of event...

Javascript TypeError for declared function

javascript,javascript-events
HTML <input type="checkbox" class="test" id="chk" /><label for="chk">Click</label> <p id="demo"></p> JavaScript (function (){ var chk = document.querySelector('.test'); function ClickTest(elem){ this.elem = elem; }; ClickTest.prototype.addListener = function() { this.elem.addEventListener('change', this.showValue); }; ClickTest.prototype.showValue = function(){ console.log('Clicked'); var d = document.getElementById('demo'); d.innerHTML = "This works"; this.test(); }; ClickTest.prototype.test = function(){...

Bind multiple events in javascript

javascript,html,javascript-events
I tried the following to change a span to red on mouseover and black on mouseout: <span onmouseover="this.style.color='red' onmouseout=this.style.color='black'">Mouse over me!</span> but it does not work! How can I bind more than one event to a single element using javascript?...

How to run a Javascript function everytime f5 is used to refresh the page

javascript,jquery,javascript-events,onload-event
The following code works for the first time that the page is loaded but when the page is refreshed using F5, it does not work on firefox. In chrome it works fine. $(document).ready(function() { $("iframe").each(function() { // Using closures to capture each one var iframe = $(this); iframe.on("load", function() {...

Track Links Using Events - Race Conditions

javascript,angularjs,javascript-events,google-analytics,adobe-analytics
I am building AngularJS applications which have common header with links to each of the application: <a href="https://app1.company.com">App1</a> <a href="https://app2.company.com">App2</a> Each application is running on its own subdomain and when user clicks a link on the header - page redirects to that application. I have to track user actions with...

ext.net button click direct events

asp.net,extjs,javascript-events,ext.net,gridpanel
I have a big form with many fieldsets and gridpanels and I need to submit all data with one confirm button. Actually I'm using this: <ext:Button runat="server" Text="Finalizar" Width="150" ID="Button1" Disabled="true"> <DirectEvents> <Click OnEvent="SalvarDados" After="#{StoreVerifLimpeza}.sync();"> <Confirmation ConfirmRequest="true" Title="Confirmação" Message="Confirm?" /> <EventMask ShowMask="true" Msg="Salvando..." /> </Click> </DirectEvents> </ext:Button> But apparently the...

Jquery Click event dosen't fire on paranet div that has same size as descendent img?

jquery,javascript-events,event-handling
The HTML code is as below (the img fits to the div parent) : <div id='draggable_task' style='display: inline-block; position: relative; overflow: hidden'> <img src='../Content/BPMN Icons/Big Icons/BigTask.png' /> <p style='position: absolute; top: 20%; left:20%;'>Task name</p> </div> The JavaScript code is as below (DrawArea is the top container): $("#DrawArea").on("click", function (e) {...

Why is my node event callback showing up in the event as undefined?

javascript,node.js,url,javascript-events
I am trying to pass back a url string as "data" into my eventhandler. My request to the server is "https://172.20.10.6/index.html". The console.log below prints out "/index.html" as I expect. switch(req.method) { case 'GET': console.log("logged from plugin-https.js: url: " + req.url); ee.emit("dataIn", req.url); break; Below is the eventHandler code. The...

Keydown and keypress events gives different keyCode

javascript,javascript-events,keypress,keydown,keycode
I've read through related answers and articles on SO, but still doesn't get it : On chrome console if I add two listeners to output keyCode on keypress and keydown events I get different keycode when the key is lowercase. When uppercase however, the keyCode appears to be the same...

dynamically added event handler disables the previous one in Javascript

javascript,javascript-events,event-handling
I am creating buttons dynamically in Javascript. Also adding dynamically an eventhandler to each button. For the last button it works but the previous ones simply are not working any longer. Here's my small piece of code. What do I do wrong? <html> <head> <script> var id = 0; function...

How do I avoid hover event to fire in iPhone and iPad?

javascript,ios,iphone,javascript-events,jquery-hover
I had added an effect on hoverEnter and hoverLeave on my Divs assuming that these events wont fire on iOS devices. But on iOS devices the hoverEnter and click event fire and the hoverEnter effect is maintained. I dont want these hover events to fire on mobile devices. What should...

Can't Add Up Radio Button Values with jQuery

javascript,jquery,html5,jquery-mobile,javascript-events
I'm trying to add up all the values of the radio buttons selected on Submit button press. It sometimes changes the 0 to a 200, but it isn't adding correctly. I'm not quite sure what is going on with this one, since the total amount sometimes changes, but isn't accurate....

Can a conditional-And operator(&&) contain more than 2 operands?

javascript,html,events,javascript-events
I asked a question in regards to this code earlier and it works to a degree after I changed it to reflect the answer but there is a bug that only really you to match red with red or blue with blue or green with green. I know that the...

Handling Alt + Enter key press in JavaScript

javascript,javascript-events,keypress,keyboard-events
I'm trying to get some pure JavaScript code to handle Alt + Enter key press event in a text area but am failing miserably. What is wrong? Html <textarea id="ta" style="width:100%;height:500px"> </textarea> JavaScript var ta = document.getElementById('ta'); ta.onkeypress = function(e) { if (e.charCode == 10 && e.altKey){ alert( "Key Pressed:...

Basic Calculator - event binding using pure javascript

javascript,javascript-events
I am completely new to the Javascript .When I am looking to get the value to the button its get failed.I already given the setEvent.Like getEle(); And also bind the click function, Now i want to get the input values and perform mathematical calculations. <!DOCTYPE html> <html> <head> <title>Simple Calculator</title>...

onended audio event firing without playing the audio

javascript,html5,audio,javascript-events
I have multiple audio files that i need to be played. and only when all audio has been played completely the next section is supposed to show. the code that i've written fires automatically without playing any audio. how should i do it? here's my code <!DOCTYPE html> <html> <body>...

Avoid onRowClick event when outputLink is clicked inside of RichFaces datatable

javascript,javascript-events,datatable,richfaces
How to avoid the call to onRowClick on the datatable on the column that has the outputlink (target to a new window)? <rich:dataTable id="dt" value="#{bean.cars} var="_car"> <a:support event="onRowClick" action="#{action.navigateToCarDetails(_car.id)}"/> <rich:column> <f:facet name="header">Select</f:facet> <a:commandLink onclick="Event.stop(event)" action="#{bean.toggleSelectedCar(_car.id)}" reRender="dt" ajaxSingle="true" limitToList="true"> <h:graphicImage...

does jquery .on() support for “load” or “ready” events?

javascript,jquery,javascript-events
For attaching click event handler to dynamically loaded html ,I could use : $(document).on("click", "Parent_SELECTOR_Available_In_Initial", function(e){ /// Do some stuff ... }); I dynamically load some html mark up and java script which contain methods need to be run on ready or load event . But $(document).on("ready", "Parent_SELECTOR_Available_In_Initial", function(e){ ///...

Invoke marshalled COM interface multiple times

javascript,javascript-events,com,event-handling,activex
I am writing a COM object for JavaScript consumption. JavaScript code is turn runs in an hosted WebBrowserControl. I need to fire some events from COM object to JavaScript, the excellent guide to which at Dr. Dobbs e.g. I have following in my *.idl IJSCallback { void Listen(IDispatch* pJSMethod); }...

How do I know, via key event code, if the character just entered in a