javascript

Display DropDown options on Focus

I have a simple html dropdown, I wants to use jQuery if possible to display all the options if this control has the focus(as if the user click on the dropdown). I have tried jQuery trigger(), click(), to avail. <select id="single"> <option>Single</option> <option>Single2</option> </select> ...

How do CSS sprites work?

I have 3 different images and want to create a sprite using CSS. I understand that will reduce HTTP requests. However, I am totally new to this concept and have no idea as to how to approach this. What would be best bet for me? Also I have seen there are some CSS sprite generators where you submit a .zip of images and it combines the...

What's the equivalent of PHP's " .= " in Javascript, to add something to a variable..?

In PHP you can do: $myvar = "Hello"; $myvar .= " world!"; echo $myvar; The output is: Hello world! How can I do this in Javascript/jQuery..? ...

Change hidden item when lightbox is open

I have a portfolio section that is set up as a main image is displayed with tiny images below it. When you click on the tiny images the main image is changed (rotator). They are changed by javascript that is run for test.html#slider1, test.html#slider2, etc. When the main image is clicked, a lightbox, or more specifically a jQuery Color...

Capture clicking on a checkbox's title in jQuery

I'd like to listen on the event of a user clicking on a checkbox's title (in addition to the checkbox itself). How can this be done? ...

Dynamically render partial templates using mustache

Is there a way to dynamically inject partial templates (and have it work the same way in both Ruby & Javascript)? Basically, I'm trying to render different types of objects in a list. The best I can come up with is this: <div class="items"> {{#items}} <div class="item"> {{#is_message}} {{> message}} {{/is_message}} {{#is_pictu...

JavaScript way to tell if an object is an Array

What's the 'right' way to tell if an object is an Array? function isArray(o) { ??? } ...

jQuery Animation and Classes

Assume you have a list item, <li id="foo"> which you want to fade from one color to another when moused over, and that you are using jQuery. This is fairly easy: $('li#foo').bind('mouseenter' , function(e) { $(this).animate({backgroundColor: '#F00'} , 300); }); However, what if you wanted to get the resulting color or other styl...

what are good ways to implement search and search results using ajax?

i have some text boxs in a page and in the same page there will be a table 'grid' like for holding the search result. When the user start editing and of the textbox above, the search must start by sending all textboxs values to the server 'ajax', and get back with the results to fill the below grid. Notes: This grid should support pagi...

Ternary Operators in JavaScript Without an "Else"

I've been using them forever, and I love them. To me they see cleaner and i can scan faster, but ever since I've been using them i've always had to put null in the else conditions that don't have anything. Is there anyway around it? E.g. condition ? x=true : null ; basically, is there a way to do: condition ? x=true; Now it shows up as...

Global variables in Javascript across multiple files

Hello, A bunch of my JavaScript code is in an external file called helpers.js. Inside the HTML that calls this JavaScript code I find myself in need of knowing if a certain function from helpers.js has been called. I have attempted to create a global variable by defining: var myFunctionTag = true; In global scope both in my HTML cod...

White-box testing in Javascript - how to deal with privacy?

I'm writing unit tests for a module in a small Javascript application. In order to keep the interface clean, some of the implementation details are closed over by an anonymous function (the usual JS pattern for privacy). However, while testing I need to access/mock/verify the private parts. Most of the tests I've written previously have...

Why does one of two identical Javascripts work in Firefox?

Hi, I have two image swap functions and one works in Firefox and the other does not. The swap functions are identical and both work fine in IE. Firefox does not even recognize the images as hyperlinks. I am very confused and I hope some one can shed some light on this for me. Thank you very much in advance for any and all help. FYI: th...

facebook XFBML is not rendering in IE8

I put up this test page to illustrate this issue: http://pix-all.com/fb-test.htm Every Browser i've tested on has worked but in IE8. The odd part is that IE8 doesn't even report an error, WOW, and that is something. So right now im stuck with to nothing to work on or debug. Hopefully you guys can help me out and spot what i've overlooke...

JavaScript tree / treegrid libraries

I'm looking for a good JavaScript tree / treegrid package. Now -- before you answer: It needs to be able to perform well with lots of nodes. Perhaps 1,000 sibling nodes. It needs to be able to draw to a usable state within 2 or 3 seconds with 1,000 nodes. It doesn't necessarily need to draw all 1,000 nodes at once -- if it supports ...

How to replace "(" and ")" with "<span>" and "</span>" jQuery

I have follow html code: <a href="#">Evente (0)</a> an i need: <a href="#">Evente <span>0</span></a> how i can change it with jQuery? ...

How to get page content using Javascript or JQuery

Hello, I will have a widget on a remote page. In the widget I want javascript or jquery to get all the article content from the webpage and send it back to my website. I only need just the article content and not all the other information on the webpage. I would like the script to send the remote webpage url, page content, title text, an...

who wrote 250k tests for webkit?

assuming a yield of 3 per hour, that's 83000 hours. 8 hours a day makes 10,500 days, divide by thirty to get 342 mythical man months. I call them mythical because writing 125 tests per person per week is unreal. can any wise soul out there on SO shed some light on what sort of mythical men write unreal quantities of tests for large soft...

triggering an onchange event of a select box

Hi all, I have a select box, which i can populate using two methods. First - Just by selecting any one of the option in the select box. Second - I have a link just beside the select box.Clicking this link takes me to a page2, which has the same options but as links in page2.When i click one of them , it populates the select box. Sele...

Question about Architecture for Viewing Images in ASP.NET MVC App

I have an approach in mind for an image viewer in a web app, and want to get a sanity check and any thoughts you stackoverflowers might have. Here's the whirlwind nutshell summary: I'm working on an ASP.NET MVC application that will run in my company's retail stores. Even though it is a web application, we own the store machines and hav...