javascript

How to make jQuery dialog modal?

I am using jQuery dialog in asp.net. It is working fine for me. The problem is when I open the dialog box, I can still work parent page functionality. I don't want that. Just dialog to modal and should not allow focus on parent page. window.onload = function onloadFunction() { //setup edit person dialog $('#uploadPic').dia...

What's the difference between String(value) vs value.toString()

Javascript has lot's of "tricks" around types and type conversions so I'm wondering if these 2 methods are the same or if there is some corner case that makes them different? ...

javascipt utility that increments/decrements to the next 15 minute interval

Can anyone find any bugs or performance improvements here? <a href='#' id='from_arrow_down' onclick="timeOffset(-1,'from_time');">Click me</a> function timeOffset(offset,time_id) { // javascipt utility that increments/decrements to the next 15 minute interval. // When user pushes a button, program will get time from input box, ...

What's up with `return function()` in javascript anonymous functions nowadays? (BEST PRACTICES)

NOTE: Updated and rewritten This question has been redone and updated. Please pardon outdated references below. Thanks. I've seen a lot of javascript code lately that looks wrong to me. What should I suggest as a better code pattern in this situation? I'll reproduce the code that I've seen and a short description for each one: Code bl...

How to set jQuery this when calling a function?

Using jQuery, I set a link tag's click handler like this: $('#lnk').click(handleClick); handleClick does something like this: function handleClick() { var $this = $(this); ... } Now I have a need to directly call handleClick() outside of #lnk being clicked. Is there a way for me to set this when calling handleClick? ...

JavaScript over/under usage. what is acceptable these days?

As a budding web developer I'm trying to walk the fine line of cross-platform usability/compatibility and pizazz(functionality). Is this as much as a problem as it was a few years ago? The parts of my site that - dare I say - require (aka make my life easier) JS would not be something that a mobile would want to access (although it cou...

Rails File Download And View Update - Howto?

Hi there, This seems like it should be straight-forward, but I'm stumped. I have a link to a view controller that ends up using send_data to download a file to the user's hard drive. This works very well, and it leaves the current view apparently untouched. But now I would like the page to provide some feedback after that download is c...

looping through dynamically created controls in jquery

I'm trying to use the following loop to loop through dynamically created controls on my web form: for(x = 0; x <= count; x++) { Stmt += $("#DDLColumns" + x).val(); switch($("#DDLConditional" + x).val()) { case "is equal": Stmt += " = "; break; ...

Odd problem with input hidden and innerHTML

I have a text area with some text. I also have an "onsubmit" event handler. In that I have an alert of the text area's innerHTML and I get back the text that is inside of the textarea. I then try to assign this to the "value" attribute of a hidden input element. However the value is never assigned, when the form posts, the hidden element...

How to insert a click function inside of a plugin call?

Inside of fullCalendar(), a jQuery plugin, I can get the value of view.visStart. Outside of the function view.visStart is not available. How can I either get view.visStart out (and is this bad because it is Global?) or how do I insert a click function within the plugin call? thanks. $('#calendar').fullCalendar({ events: "js/events.j...

Keyboard accessible web dropdown menus?

Is there a way to build keyboard accessible dropdown menus on web sites? Our current web application has standard hover menus, but this really slows down our data entry clerks (who are accustomed to desktop apps where there's a keyboard accessible menu and no need to use a mouse). We figured out how to show the menu with a keyboard s...

Promoting a function to global for performance reasons?

I was looking at some code and have seen these comments, how does promoting a function to global help performance? // this function is promoted to be global // to make firefoxs jit happy - URGH function clamp(x, min, max) { if(x < min) return min; if(x > max) return max-1; return x; } ...

How long should a page take to render after it has been received?

Possible Duplicate: What do most users consider acceptable load times on a website? How long should a page take to render after it has been received? I'm talking about initialization javascript and css. I know this should be considered with what an acceptable overall load time should be. And, I would like to see numbers on th...

javascript onerror function doesn't execute in the normal sequential flow?

hello, my code is something like this: function func1() { document.getElementById("img").src="pic.jpg"; ---stament2---; } document.getElementById("img").onerror="func2()"; In other browser, if there is no pic.jpg, func2() is executed and AFTER that, stament2 is executed; in opera if there is an error loading the image, f...

Prototype - click event by element class name

I am new to the prototype framework and am trying something really simple and failing. I am trying to respond to a click event on a button like so: $$('.btn').observe('click', respond); function respond(event) { alert("hello"); } Why isnt this working?? Please help! ...

Converting a string into a Date via javascript

I have a string I need converted into a date: 2010-10-14T09:00:00.0000000 In FF and Crome I can do var date = new Date("2010-10-14T09:00:00.0000000") and everything works. That code in IE, Safari and Opera gives be a NaN. How can I get that string into a date in a x-browser manner, preferably without manually parsing the string into i...

Underscore.js: how to chain custom functions

Using Underscore.js, I can write the following which returns 42: _([42, 43]).chain() .first() .value() I have custom function, not part of Underscore.js called double(): function double(value) { return value * 2; }; I would like to be able to call this function in an Underscore chain, as if it was part of Underscore. I woul...

transparent borders with css 3

Is there a way to make the borders of an element semi-transparent? using purely css? like the modal window that facebook uses? ...

How can I create a div which resizes with a window?

I would like to create a div using css that resizes with the window. Example: #container { margin: 3em; } #header { height: 100px; } #main { } #footer { height: 100px; bottom: 0px; } container header main footer So when I resize the window, I want main to resize w...

Jquery dialog stop closing when error occured?

I am using the jQuery Dialog in ASP.NET. I have it working fine with the exception of when I click the OK button in the dialog and if an error occurred I want to show the error in the label. By the time the dialog closing event is fired it is too late. How do I still show the dialog if an error has occurred. I don't want to close the dia...