javascript

Merging JavaScript files together on the fly in ASP.NET

Is it possible to merge several JavaScript files being used on a site into one? I'm looking to do this to minimize server loads by forcing only one download. This way I can keep my JavaScript organized into separate files and still have efficiency. ...

Should you add HTML to the DOM using innerHTML or by creating new elements one by one?

There are two methods to add HTML-code to the DOM and I don't know what is the best way to do it. First method The first way is the easy one, I could simply add HTML-code (with jQuery) using $('[code here]').appendTo(element); which is much like element.innerHTML = [code here]; Second method Another way is to create all the elements ...

Sticky headers in complex web form (a la iPhone)

I'm designing a complex web form (for trained users, not drive-bys) that has many sections, many of which contain subsections. The form could become quite long, depending on the situation. Usability would be greatly enhanced if (sub)section headers would remain visible until the (sub)section has completely scrolled past. For example, wh...

jQuery code for sliding div (accordion)

I am looking for some good jQuery, XHTML & CSS code to achieve the effect as seen in the following image: http://i48.tinypic.com/a3o4sn.jpg Obviously this is a static image, what is supposed to happen is the text and the transparent background is hidden, and when you put your mouse over the image it slides up into view and down again o...

Calculate how much bigger one image is from the other one.

Some math calculations in JS problem solving I am working on a zoom image functionality that creates a new div with a large image that is moved through x and y according to the mousemove on the image. The large image should move a certain %, which is what i am trying to figure out. How much should it move by. Here is some info: T...

Supressing form post on enter when a textbox is empty

I am using MVC, not that this makes a difference, but I have a text box for searching. <% using (Html.BeginForm("Index", "Search", FormMethod.Post)) { %> <%= Html.AntiForgeryToken() %> <div id="search_box"> <span id="search-title">Search Site</span> <div> <%= Html.T...

unterminated string literal

I getting any error on a I'm creating in my client side code. The issue seems to be coming from the "onclick" that I'm adding to the row. You can see the function below. Then underneath that is what the "this.clickvalue" actually equals that on the line that is giving me the "unterminated string literal" error. 51 var row = "<tr " +...

Is there a way to connect dijit.form.DropDownButton.openDropDown() (or closeDropDown()) on mouse up ?

Hi. In dojo 1.4 default, dijit.form.DropDownButton.openDropDown() and closeDropDown() are connected to mouse down event. Is there a way to connect them not to mouse down but to mouse up event ? I want to realize draggable DropDownButton and open/closeDropDown() invoked just after mouse down is too early. ...

Function not found in jTemplate

Hi, I'm having a weird issue with a function I'm trying to call from within a jTemplates template giving the error "XYZ.getFriendlyName is not a function". It seems like I must have overlooked something simple, but I've tried everything I can think of and the error persists. The code looks like this: <input type="text" value="{#if $T.R...

DatePicker no longer working after changing a C# webapp to use a master page.

I'm working on a .Net/C# web application and had been using a javascript based calendar to allow users to select dates. This has been working fine. Today I changed the code to include a master page and the datepicker which is called from a childpage has stopped working, the problem being that the Textbox which the date is returned to i...

Supporting Multiple JS libraries

I have developed one of my modules using Dojo. Its gone really well and I have done a lot of custom plugins and server support in Dojo to allow AJAX calls, RPC + SMD communication with my server. However, now that I am getting onto the user side of things, I am seeing that jQuery has some really nice already built plugins. Do you think...

How do I SET a Cookie (header) with XMLHttpRequest in JavaScript?

I'm trying to set a Cookie in a XSS request using XMLHttpRequest. I found the XMLHttpRequest Specification, and section 4.6.2-5 does seem to suggest that setting Cookie, Cookie2, and some other headers are not allowed, but I was hoping there was a work around. My (jQuery) code is below, but the resulting query fails as the cookie is NO...

how to add li between each li using Jquery

Hello i have this HTML CODE <ul id='container'> <li>a</li> <li>b</li> <li>c</li> <li>d</li> <li>e</li> <li>f</li> </ul> i want to add <li class='separator'></li> between each li's, at the beginning and at last. so my example will look like this: <ul id='container'> <li class='separator'></li> <li>a</li> <li class='separator'></li...

Function values in JavaScript

nextplease.init = function() {...} is a function with no arguments. I'd expect nextplease.init and function() {nextplease.init();} to behave identically. Is there any possible difference between them (obviously, you can assign something to nextplease.init, but let's exclude that)? In particular, can there be a difference in behavior bet...

jQuery replace text leaving siblings intact

Hi, I'm having trouble wrapping my head around what should be a simple solution. I want to replace text within a label tag, without affecting the other 'siblings', if they exist. Sample markup: <fieldset class="myFieldsetClass"> <legend>Sample Fieldset</legend> <ol> <li> <label> <span class=...

Make array of data from $(this).serialize()

Hello, I have a product page wherein if the user clicks on edit, an overlay form window is populated to make it editable. After the edit is completed and the user clicks submit I want to update the text() of each field of the product which was changed. So instead of getting value of each input field and updating is there a way I can u...

Is enabling JavaScript in browser a MUST to get working ASP.NET pages?

This is a newbie question (I'm sure it is). I have tried for the first time in a little ASP.NET web application I am working on what happens if I disable Javascript in a browser (I'm testing mainly with Firefox). Result: My application is completely broken, although I didn't ever write any single line of Javascript. For instance: I ha...

Forcing cache expiration from a JavaScript file

I have an old version of a JS file cached on users' browsers, with expiration set to 10 years (since then, I have learned how to set expires headers correctly on my web server). I have made updates to the JS file, and I want my users to benefit from them. Is there any way my web server can force users' browsers to clear the cache for t...

How to solve this using jQuery

Hi All, I have one html structure , somethinh like <div> <div id="mydiv"> <h3> This is a Test Page </h3> <div>I am inside a div</div> <a href="http://www.google.com"&gt;Click me</a> <div>Second div</div> </div> </div> and one script: $(function () { var elm = d...

Can we display Hyperlink from Javascript alert on ASP.NET Page?

Hi I have the following text that needs to be displayed from Javascript ALert. I am wondering if we can display the hyperlink from the alert itself? alert('User already exists in the system, please <a href='../Login.aspx'>login</a>'); Appreciate your responses Thanks ...