In my Backbone View, I have defined events like this: I have bound single and double click event listeners to same element .elm. When I double click on this element, I get this output: single clicked single clicked double clicked Tried preventDefault() and stopImmediatePropagation() and that didn’t solv…
Tag: javascript
How to read and write JSON offline on local machine?
Problem I need a way to store and collect JSON data in an entirely offline(!) web application, hosted on a local (shared) machine. Several people will access the app but it will never actually be online. I’d like the app to: Read and write JSON data continuously and programmatically (i.e. not using a fi…
Regex for allowing alphanumeric,-,_ and space
I am searching for a regular expression for allowing alphanumeric characters, -, _ or spaces in JavaScript/jQuery. How can this be done? Answer Try this regex:
execute javascript from textarea
I’m not entirely sure if this is possible, but I’m trying to create a mini faux editor in a browser that runs javascript on the page. Here’s what I’ve been trying to do in theory HTML javascript more specifically I’m trying to write to a canvas element via the ‘code’ …
Add/delete row from a table
I have this table with some dependents information and there is a add and delete button for each row to add/delete additional dependents. When I click “add” button, a new row gets added to the table, but when I click the “delete” button, it deletes the header row first and then on subs…
How do I implement JavaScript onmouseover in CakePHP?
What I want to do is convert the following to work with CakePHP: I have the following so far: The problem are the onmouseover & onmouseout event lines. I need to tell cake to somehow use the helper method otherwise it just selects no image. I don’t want to have to put the entire address in as the is…
How to generalize this script for multiple popups on mouseover
I have a script that works to switch between two popups that are triggered by an onmouseover event. One feature of this is that the popup persists until the next onmouseover event. I want to have many of these and so the popup to be hidden can not be ‘hard coded’ as in my script. Is there a way to
TypeScript static classes
I wanted to move to TypeScript from traditional JS because I like the C#-like syntax. My problem is that I can’t find out how to declare static classes in TypeScript. In C#, I often use static classes to organize variables and methods, putting them together in a named class, without needing to instatiat…
What’s the difference between deferred scripts and scripts placed at the end of the page body?
HTML5 introduced the defer attribute for scripts whose loading can be deferred in a HTML page. defer may be used for any scripts that don’t need to be loaded before the DOM (a.k.a don’t mess with the DOM before it is ready). For a long time web developers have been advised to put all scripts that …
Javascript Validation for a phone number (Numbers, spaces, dots, hyphens)
So I have this validation for alphanumeric’s (/^[A-Za-z0-9,+-]+$/) however I want a validation for a phone number which only allows Numbers, Spaces, Dots and Hyphens. What code would I use to check for those. Thanks Ben Answer According to my specifications its just Numbers, Spaces, Dots and Hyphens onl…