javascript

Auto-format structured data (phone, date) using jQuery plugin (or failing that vanilla JavaScript)

I like jQuery and I was wondering if anyone have used a good plugin or (non-jQuery) JavaScript library that allows for auto-formatting of structured fields like phone numbers or dates. I know of the jquery-ui-datapicker plugin, and not what I am looking for here. You may type in a phone number as 123 which then becomes (123), additiona...

Can an element's CSS class be set via JavaScript?

I want to do this: e.className = t; Where t is the name of a style I have defined in a stylesheet. ...

What javascript tutorials on the web would you recommend?

Already know of one very good resource: Douglas Crockford's videos over at Yahoo UI Theater. Please suggest any others you are aware of. ...

What are JQuery's limitations?

Joel always said to be careful when using 3rd party libraries. From my initial impressions, JQuery is great. What should I beware of when using it? What are it's limitations? What headaches will I run into later on as I use it more? ...

Re-ordering entries in a model using drag-and-drop

Say I have a blogging app in Django. How can i re-order the posts using a draggable table in the default admin? It would be best if i didn't have to add any extra fields to the model, but if i really have to i can. ...

How does a javascript closure work ?

Like the old Albert said : "If you can't explain it to a six-year old, you really don't understand it yourself.”. Well I tried to explain JS closures to a 27 years old friend and completely failed. Can anybody consider than I am 6 and strangely interested in that subject ? EDIT : I have seen the scheme example given in SO, and it did n...

Best content type to serve JSONP?

I have a webservice that when called without specifying a callback will return a JSON string using application/json as the content type. When a callback is specified it will wrap the JSON string in a callback function, so it's not really valid JSON anymore. My question is, should I serve it as application/javascript in this case or stil...

How do you performance test JavaScript code?

CPU Cycles, Memory Usage, Execution Time, etc.? Added: Is there a quantitative way of testing performance in JavaScript besides just perception of how fast the code runs? ...

How do you fix the flickering that occurs when you use slideToggle in jQuery?

I have a simple unordered list that I want to show and hide on click using the jQuery slideUp and slideDown effect. Everything seems to work fine, however in IE6 the list will slide up, flicker for a split second, and then disappear. Does anyone know of a fix for this? Thanks! ...

Create query parameters in javascript

Is there any way to create the query parameters for doing a GET request in javascript. Just like in python you have urllib.urlencode() which takes in a dict (or list of two tuples) and creates a string like 'var1=value1&var2=value2' ...

Javascript interpreter to replace Python

In terms of quick dynamically typed languages, I'm really starting to like Javascript, as I use it a lot for web projects, especially because it uses the same syntax as Actionscript (flash). It would be an ideal language for shell scripting, making it easier to move code from the front and back end of a site, and less of the strange syn...

JavaScript string concatenation

Hi, On my team, we usually do string concatentation like this: var url = // some dynamically generated URL var sb = new StringBuffer(); sb.append("<a href='").append(url).append("'>click here</a>"); Obviously the following is much more readable: var url = // some dynamically generated URL var sb = "<a href='" + url + "'>click here</...

How to auto-focus RTE editor inside firefox?

We have a RTE editor based on htmlarea which consists of content with editmode enabled inside an iframe. The question is how to automatically bring the focus into the editor. ...

Javascript error

Hi! I'm getting a JS error on displaying a page: Nothing concrete is specified but the line where it seems to be thrown. When looking into the source code of the page, I see the error is thrown inside the following script, but I can't understand why! It's only about loading images! <SCRIPT language=JavaScript> <!-- function newImag...

Combining Scriptaculous and JQuery in a Rails application

I've got the following situation A rails application that makes use of rjs / Scriptaculous to offer AJAX functionality Lot of nice javascript written using JQuery (for a separate application) I want to combine the two and use my JQuery based functionality in my Rails application, but I'm worried about JQuery and Scriptaculous clashin...

Add options to select box without Internet Explorer closing the box?

Hi, I'm trying to build a web page with a number of drop-down select boxes that load their options asynchronously when the box is first opened. This works very well under Firefox, but not under Internet Explorer. Below is a small example of what I'm trying to achieve. Basically, there is a select box (with the id "selectBox"), which ...

Including a WebService reference in a control

I've written a control in C# that overrides the built-in DropDownList control. For this I need a javascript resource included, which I'm including as an embedded resource then adding the WebResource attribute, which works fine. However, I also need to reference a webservice, which I would normally include in the scriptmanager on the p...

Hiding toolbar / status bar with javascript in CURRENT browser window?

Is there some way to hide the browser toolbar / statusbar etc in current window via javascript? I know I can do it in a popup with window.open () but i need to do it this way. Is it possible at all? ...

How do I cancel a text selection after the initial mousedown event?

I'm trying to implement a pop-up menu based on a click-and-hold, positioned so that a (really) slow click will still trigger the default action, and with the delay set so that a text-selection gesture won't usually trigger the menu. What I can't seem to do is cancel the text-selection in a way that doesn't prevent text-selection in th...

Javascript curry - what are the practical applications?

I don't think I've grokked currying yet. I understand what it does, and how to do it. I just can't think of a situation I would use it. Where are you using currying in javascript (or where are the main libraries using it)? DOM manipulation or general application development examples welcome. EDIT: One of the answers mentions animation....