javascript

jquery plugin extend problem

Hi everyone this is my first post so I hope I am posting to the right place. I am trying to develop a dialog/modal plugin. this is my first plugin and I'm not sure if I have produced it in the correct way. The problem I am having is that the $.extend is not updating the settings object. I've got 2 elements using the plugin. the #dialog...

Losing MouseUp event if releasing not over the same element

I have got a problem with a slider. When i grab the handler, i change the .src of the image, just to change its color. However, i want it to change back to the original color when i release the mouse button. I have tried two things. 1) Changing it back on the handler mouseup event: this works only if i release the button over the handle...

Is there a way to detect, through browser javascript, multi-touch events of a trackpad, magic mouse or magic trackpad on a mac?

I know there are many ways to do so directly on the iPhone (jQtouch), but I'd like to detect those events in my computer's browser. ...

How to prevent form submission and make jquery ajax call instead

I have an event to capture when the return key is pressed on a form input field, but the ajax call is not fired, instead the from is submitted as a normal http request. $("#addurl").keypress(function(e){ switch(e.keyCode){ case 13: // add url ajax call $("body").html(ajax_load) ...

Access all local variables

Every global variable in javascript is a property of 'window' Apparently all local variable (aswell as arguments) are stored as properties of the 'Call object' (See chapter 4.6.2 of each function. Persumably only existing for the lifetime of said function. Basically I want to be able to do for (var obj in CallObject ) { // } Can I a...

best way to convert date from javscript string in format YYYYMMDD to javascript date

What is best way to convert date from javscript string in format YYYYMMDD to javascript date format. var from_date = document.getElementById('from_date').value; var YYYY = from_date.substring(0,4); var MM = from_date.substring(4,7); var DD = from_date.substring(7,8); ...

Can I execute js files via php?

The situation is next: I have php file, which parses a web-page. on that web-page is a phone number and it's digits are mixed with each other. The only way to put each digit on the correct place is to use some JS functions (on the client side). So, when I execute that php file in linux console, it gives me all that I need, except js fun...

Flash Before Unload Event

I am looking for a consistent way to determine when Flash is going to be unloaded. I need to handle this event in order to call a tracking API once rather than each analytical event. Any suggestions on how to consistently (across all browsers) handle this would be really helpful and much appreciated. Thanks in advance. ...

Javascript and jQuery getting the right this

I have some sample code that looks like this: var myDrawingArea = new DrawingArea(document.getElementById("drawing_canvas")); function DrawingArea(aCanvas) { this.brushSize = 2; this.buildToolbar = (function () { $("#brush-size") .slider({ value: this.brushSize, // this is DrawingArea insta...

What are the common mistakes to avoid when coding javascript for Internet Explorer?

I'm about to start coding a new, javascript-heavy website, but before I start I'd like to minimize my debugging time in Internet Explorer by knowing beforehand what the quirks are. I'm not planning to worry too much about IE6. What are the common mistakes/differences to avoid in javascript code that work fine in other browsers, but brea...

Javascript: Alert user without using an alert box.

I'm trying to find an elegant way to inform a user that s/he is about to be logged out and I know that most browsers will give you some indication that a hidden tab has an alert box open. I would like to duplicate this functionality without actually showing an alert box. I have thought about forcing the tab/window to gain focus, but tha...

JSpec vs Jasmine vs QUnit for javascript and jQuery testing in Rails

I am looking for a unit testing framework to use with javascript that integrates well with Rails 3.0 Anyone with experience with above frameworks can share their experience? ** UPDATE: JSpec is now discontinued as per their Github repository: http://github.com/visionmedia/jspec so this leaves Jasmine and QUnit ...

Benefits vs. Pitfalls of hosting jQuery locally

We're currently pulling jQuery and jQueryUI (and jQueryUI CSS) libraries from the google CDN. I like this because I can call google.load("jquery", "1"); and the latest jQuery 1.x.x will be used. Now I am to pull the libraries locally because of security. I'm happy to pull them locally but I'm wondering what are some of the other benef...

Pick up date, add day and put back

I want to pick up date from screen, add 1 day and put back to screen. <input type='text'value='20101231' id='from_date'> <script> function date_move(direction){ var from_date = document.getElementById('from_date').value; var YYYY = from_date.substring(0,4); var MM = from_d...

Is there a more advanced (more extjs-like) JQuery-compatible UI toolkit? JQueryUI looks too humble.

Is there a JQuery-compatible JavaScript/CSS UI toolkit for building complex rich web application UIs (like ExtJS is, for example)? ...

JQuery Autocomplete with URL service error

Hi, I'm trying to implement a JQuery autocomplete widget based on a php service I have built. Right now, for testing, the service is extremely simple and only returns an array of three names. While debugging with firebug, I'm noticing my service is returning a code 200, but there is no response text that comes along with it. Obviously, ...

Implement Unobtrusive Javascript with Parameters

What's your strategy for passing parameters to unobtrusive Javascript? Say we have three dynamically generated input fields which need to be validated for ranges: <input id="smallValue" class="validatedRange" /> <input id="mediumValue" class="validatedRange" /> <input id="largeValue" class="validatedRange" /> In the Javascript: Ext....

jquery plugin public function

This is my plugin (function($){ $.fn.editor = function(options){ var defaults = {}, settings = $.extend({},defaults, options); this.each(function(){ function save(){ alert('voila'); } }); } })(jQuery); I want to call function save from outside the plugin....

What are the benefits and dangers of adding methods to Object.prototype in Javascript?

I know this was a contentious issue five years ago, but I'm wondering if things have changed for today's JavaScript. Are there any real world examples of a major modern library being incompatible with extending Object.prototype? I'm not interested in hypothetical "someone may write bad for in iteration code in a library that you want to...

How does modernizr check support for the new input attributes in webforms2.0?

Well, that's pretty much my whole question. I can see how they check for CSS3-support, trying to fetch style.borderRadius and such to see if the browser knows what the heck is going on. But since most browsers will let the attribute stay (<input type="date">), but still not support it fully, I can't understand how they do their magic. ...