javascript

How to stay DRY when logic needs a C# and Javascript implementation?

I'm currently using the ASP.NT MVC RC1 to implement a basic timesheet application. I'd like to follow the DRY principles but finding it difficult in one particular case: One of my views, a partial view actually, has a number of textboxes that represent the number of hours spent on a particular task, one textbox per day of the week. When...

Creating an image with canvas in Javascript

I seem to have hit an error message that I'm having a hard time debugging. What I'm trying to do is dynamically create an image such as this one ( http://www.webreference.com/programming/javascript/mk/column3/creating/cp_mini_gradient_details.png ) with canvas. The error message I'm getting is: [Exception... "An invalid or illegal str...

Cons of external JavaScript file over inline JavaScript

What are some of the disadvantages of using an external JS file over including the JS as a part of the ASPX page? I need to make an architectural decision and heard from coworkers that external JS does not play nice sometimes. ...

VS Builtin web server sends images as octet-stream

I am debugging an ASP.NET website which has a lot of javascripts and images using Visual Studio 2008 development web server. One of the many scripts try to create an <img> tag on the fly and supply it with a proper src attribute. However, none of the images are loaded and instead alt text are displayed in Firefox, IE and Opera. Digging...

jQuery change() on <select> and firefox

I have a dropdown that triggers an ajax call when its changed: $('.travel-to').change(function(){ $.ajax({ type: "GET", url: "/inc/rates/rates-viewer.php", data: "shtech=y&c_name="+escape($(this).val()), success: function(html){ $(".rates-viewer").html(html); $(".rates-viewer tr.numbers td").css({ opacity: 0 }).fadeTo("...

Javascript in IE vs Firefox

The following script works fine in IE7 but fails to execute in Firefox 3. The div tag which was display: none; shows in IE but never in FF. I am not a client / javascript guy... thanks. <script type="text/javascript"> //<![CDATA[ document.getElementById("Fred1_Panel").style.setAttribute("display","inline");//]]> </script> ...

Why is my thead not appearing in Internet Explorer?

I have made a table with a thead (header); on a Mac, and in Firefox everything is fine, but on Internet Explorer 6 the head is just gone... Any idea why? Here is the link to test it: http://www.acecrodeo.com/new/05-rodeos.php... The table is constructed in tablerize.js: jQuery.fn.tablerize = function() { return this.each(function(...

Good ASP.NET excel-like Grid control?

We are looking for an ASP.NET compatible data grid that allows for multi-line editing similar to Excel or a WinForms data grid. It must also support very basic keyboard input (tab, arrow keys, return). Note that we are not looking for Excel capabilities (functions, formatting, formulas) ... just a grid for fast data entry. I've looked...

Is it possible to trigger a jQuery click event on a background-image in a list?

I have an unordered list of items, something like this, shortened for brevity: <div id="elementsContainer"> <ul> <li><a>One</a></li> <li><a>Two</a></li> </ul> </div> I have the list styled up, but these 3 styles deal with background images for the list items: #elementsContainer ul li { list-style:none; } #elementsCont...

How do I get intellisense for WCF Ajax Services?

I've finally got Intellisense working for JQuery by applying patch KB958502 to Visual Studio 2008 and including this line: /// <reference path="JQuery\jquery-1.3.2.js"/> at the top of my .js files. Now I'm trying to figure out how to get JavaScript intellisense for the client proxies generated by the ScriptManager's ScriptReference e...

Javascript Functions and optional arguments

I have two nearly identical javascript functions that are used to initiate a jquery $.get call. The arguments to the function are passed to the script being called. The problem is that one set of calls requires an additional argument that the other does not. To accomplish this I'm using the two nearly identical javascript functions I'v...

Can Javascript force hidden divs to wait to load their contents? (HTML/Javascript)

I have a fairly basic thumbnail-and-view page going. As each thumbnail is clicked, the central pane shows the full-size image. This bit works fine - I'm using Javascript to show and hide the divs which contain the large images, but as the page first loads, it starts loading all of the images at the same time. This causes the first ima...

Can I proxy a select field with HTML and javascript?

Since <select> elements don't style in a predictable way, I was thinking about setting up a javascript/html proxy element to manipulate a hidden <asp:dropdownlist> field. The code that populates the select is beyond my control, but I don't want to render the actual field. Does anyone have any experience or pointers with something like t...

How to abort the loading of an external HTML resource, from JavaScript?

I'm writing a JavaScript widget, which is intended for use on other website and loads additional script files from my own web site (which basically means no XHR due to cross-domain limitations). Now I want to handle failures gracefully - if one script fails to load, I want to load the script from an alternate server. I managed to handle...

How to iterate over every property of an object in javascript?

Is there a way to iterate over every property of an object using the Prototype JavaScript framework? Here's the situation: I am getting an AJAX response in JSON that looks something like this: {foo: 1, bar: 2, barobj: {75: true, 76: false, 85: true}} If I evaluate that json response in to a variable response, I want to be able to ite...

Passing a jQuery event as a variable

You can do this with JavaScript: function bar(test) { alert(test); } var foo = bar; foo('hi'); I'd like to be able to do something similar with a jQuery event: var foo = $('#bork').click; foo(function() { alert('I was just clicked.'); }); However, I get an error when the page loads: this.bind is not a function. Am I doing somet...

Best practices for declaring functions inside jquery ready function

Hello everyone, I haven't found a good reference for declaring my own functions inside the jquery.ready(function(){}); I want to declare them so they are inside the same scope of the ready closure. I don't want to clutter the global js namespace so I don't want them declared outside of the ready closure because they will be specific t...

ASP.NET, Visual Studio, C# and Javascript

I have a simple ASPX page based of a master page. On the ASPX page, I have two drop downs and a button. When pressing the button, I want to execute some javascript. To do this, I have used the Button's attribute collection (Add("onclick", script)). My script looks like this: string script = "return confirm ('You have selected' + docume...

Is JavaScript's Math broken?

0.1 + 0.2 == 0.3 // returns false 0.1 + 0.2 // returns 0.30000000000000004 Any ideas why this happens? ...

window.onload vs document.onload

Which is more widely supported, window.onload or document.onload? ...