javascript

How does ASP.NET MVC Generate JsonResults?

I want to inject some Json into the Html page returned by the server? Is there a public function that returns the Json string when Json(someObject) gets called? Note that I don't want to return Json to the browser in a seperate request. I want to convert an object graph to json and inject it into a script block. Thanks ...

how to remove non 'ui-*' words by invoking str.replace() with regexp

In Javascript, str = 'left ui-tabs ui-widget ui-widget-content center right'; Is it possible to remove non 'ui-*' words by invoking str.replace() with regexp ? The result after invoking str.replace() should be: str.replace(/ /, '') = 'ui-tabs ui-widget ui-widget-content'; I've tried some regexp patterns, but they doesn't work. ...

Background Image in an Image Map

I am trying to make a user generated nav bar. This nav bar because it is dynamically created may have more tabs on it than the width of the nav bar. That being the case, I would like to make it so that the nav will scroll from left to right. Currently I use an image mapping technique where I plot coordinates on an image and move divs ...

Losing focus on parent element when hovering child element in prototype

I have a div where when I hover over it I have a child div (another div) to animate, but when I hover over the child div, the parent div loses focus and the child element starts animating back as if I left the parent div. Here is the code I am using: $$(".slide .item").each(function (element) { element.observe('mouseover', function (e...

dojo drag and drop: don't want to sort items

I have a dojo.dnd Source object that I just want to list out normally, without the user being able to sort the objects. Is this possible? ...

How can I check to see if a child browser window has finished loading?

I have a link on a page that pops up a new window, and sometimes that second window takes a long time to load. I want to disable the link on the parent window until the child window finishes loading. I know I can have the child window onload() to alert the parent, but I don't want to mess with the child, so I have a little javascript tha...

Difference between JS style.display and .NET visible

I have seen some instances where people will say you have to use JS .style.display = 'none'; and that .NET .Visible = false will not work. What is the difference between the two and why would something work with the JS and not with the .NET? An example is http://www.componentart.com/forums/ShowPost.aspx?PostID=27586 (see the bottom pos...

Accessing C# Variable from Javascript?

In my MS SQL table, I read in an "time_zone" for a city from a record. I then want to use this time zone in a Javascript function to create a digital clock for that city. Currently I am trying to set the time_zone variable from Here's a code snippet from Default.aspx: function showtime() { zone(hiddenZone...

Can I use GWT (or Script#) to write individual functions in Java (or C#) and compile them to JavaScript?

I understand the purpose of GWT, but I'm wondering if I can use it to compile a few functions from Java to JavaScript just to make sure that I don't have to maintain the same code in two different languages. Or would GWT bring along too much library/support overhead along to make this a reasonable choice? For future projects, I have th...

jQuery UI dialog - unable to remove buttons.

How do I remove the buttons in a jquery dialog? Per example, I tried re-calling .dialog with the correct new options, but the dialog seems unaffected. $('.selector').dialog('option', 'buttons', {} ); does not work, and nor does it work if actual new button strings and functions are declared. Thoughts? ...

Weird IE javascript error

For some reason when I run my game in IE it stops during the preloader. I opened up IE8's debugger and it failed on this line complaining about some run time error. document.getElementById("mainpreloaderscreen").innerHTML=loaded+"/"+total+"<br><button onclick=\"gamepreload('all')\">load all (not recomended)</button>"; Why does IE do ...

Is MVVM possible/viable in a DHTML RIA application (no Silverlight/WPF)?

Note: This is a long winded question and requires a good understanding of the MVVM "design pattern", JSON and jQuery.... So I have a theory/claim that MVVM in DHTML is possible and viable and want to know if you agree/disagree with me and why. Implementing MVVM in DHTML revolves around using ajax calls to a server entity that returns J...

Generate a random number based on another variable

I have a timer that grabs a file every 10 seconds: if((Timer%10=="0")||(Timer=="1")){ I also have a random number generator: var randomNum = Math.floor(Math.random() * 10) + 2; I also have a variable which stores the time remaining: Timer=0; function countdown(auctionid) { var auctions; var divs; Timer=Timer+1; i...

Emulate a file upload click in jQuery

I have an <img ... /> tag that I have bound a click event to in jQuery. When it is clicked I'd like to have it emulate the click of a button on the file upload to open the file system browse pop-up. I've tried these things within the click function and had no success: ... $(".hiddenUploadBtn").click(); ... ... $(".hiddenUploadBtn").sel...

javascript to get system double click interval?

Can I use javascript to get the system's double click interval? ...

how to get a value of parent id with jquery

Hello, This is the html i am using <tr> <td>No.</td> <td id="2" class="editable">data1</td> <td id="2" class="editable">data2</td> <td>Usage Left</td> </tr> <!-- Multiple rows with different ids --> and this is my javascript $(function(){ $('.editable').editable({onSubmit:Update}); function Update(){ var id = ...

JQuery. Simple drop down selection menu behavior question.

Hello, I have a simple html option/select (dropdown) menu. I want to use JQuery to redirect links when an option is selected. I have a "go" button in noscript tags in case javascript is disabled, but in the case that the user has javascript..I would like the redirection to happen automatically on-click. Could somebody please guide me ...

Javascript centering a div on the page

Hey, For javascript I use the jQuery framework but can easily integrate any javascript functions into it. The problem I have is I have a div that fade's in when I click a link. How can I get it to align in the center of the page and stay even when scrolling. Below is an example of what I currently have implemented: HTML code: <div i...

Javascript include_once

Hi! I have coded a page that has two div one beside the other. The first one serves as a nav tree that, when clicked, loads a page in the right div with AJAX. I have to include a javascript file when one of the page is loaded. I have managed to do jsut that and all works perfectly but each and every time that someone want to see the pa...

Understanding javascript bitwise NOT

Thanks to everyone in advance - alert((~1).toString(2)); outputs: -10 but in PHP/Java it outputs 11111111111111111111111111111110 Am I missing something, why does Javascript add a "-" to the output? Thx, Sam ...