javascript

jQuery Dialog not appearing when called.

I am trying to get a modal loading dialog to pop up while I make an ajax call but it is not showing up in the onClick function. If I slow it down with firebug and step through the loading panel will show up. Is this just javascript running ahead of itself? Is there a better way to do this? $(function(){ $("#loading_panel").dialog({...

Reference Instance Variables in Javascript Constructor

I'm trying to maintain state on an object by doing something like this: obj = function() { this.foo = undefined; this.changeState = function () { (function () { this.foo = "bar" })(); // This is contrived, but same idea. }; }; I want to set the instance variable foo to "bar" when I call the changeState method. ...

reload a page without losing field values like in FireFox using javascript

Hello, fyi I'm very new to javascript and html. I have a simple html form that has some select fields. When the user selects the options from the fields, a function is called that takes the values of the fields, multiples the values against other field values and spits out the results to an input text field named "result". This is all ...

get facebook user session after it over

hey i am using facebook connect and authenticate the user with it. for each user there is session key that expire after X minutes. how can i get the user session after the session is over ? i try FB.Connect.requireSession(); but i dont want to use this function because it pops up the facebook connect username and password. i wan...

Disable click handler when click is fired in jQuery

We have a website built in .NET and jQuery. We have custom jQuery to call the load method on a processing ASP.NET page. That ajax call is fired in a click handler, e.g. $("#Submit").click(function(){ $(a_selector).load("Process.aspx?data=" + someDataObject, null, function(){ alert("Done")}); } return false; ); Our issue is w...

How to stop the form submitting?

In a MVC view, I have a form as below. when user click on the submit button, I want to check somthing firstly. If it is ok, submit the form. If not pass the checking, give user a alert message, then stay in the view. My sample code as: <script type="text/javascript"> function CheckingStatus() { //..... if (answer == "N") { ...

Which datastructure is this? - Javascript

I came across a code snippet in JS globe = { country : 'USA', continent : 'America' } Using the variable declared above by: alert(globe.country); Questions: Is this a JS class with 2 members? Why is the var keyword not used when declaring globe? If it's a class, can I have member functions as well? Thanks ...

Super class methods in javascript

I am writing some objects (classes I guess) in javascript. Class B inherits from Class A. Class A has a method called isValid, and class B overrides that method. I am using the YUI extend function to have Class B extend Class A. A = function(){ } A.prototype = { isValid:function(){ /* Some logic */ return booleanValu...

My ActionScript's ExternalInterface callback function isn't going through. How can I debug it?

Help, please? It appears that my callback function isn't being called...back. I'm using jQuery, and Flash 8. To access the Flash object, I'm using the jquery swfobject plugin, c.f. (http://jquery.thewikies.com/swfobject/examples). If you think that I'm not accessing the SWF properly in the first place, please recommend code as to how I w...

Please help me debug this javascript

Would someone please review this code and tell me why the for loops are going infinite? I need a fresh set of eyes. Thank you! var routeData = [{"id":1,"c1_id":43,"c2_id":56,"cost":20,"c1_x":658,"c1_y":68,"c2_x":568,"c2_y":149,"owned":false},{"id":2,"c1_id":27,"c2_id":56,"cost":25,"c1_x":571,"c1_y":10,"c2_x":568,"c2_y":149,"owned":false...

JQGrid How do I removed the annoying horizontal scrollbar when autowidth = true? (In IE)

I seem to be getting an annoying horizontal scrollbar when using autowidth=true in IE What is going on here and how do I get rid of it? ...

Esoteric JS Question

Is there any particular reason that this sort of construct would not work in JS? (JSLint does not accept it.) (function(function(){ }){ })() I can see this type of chaining going on forever, or at least as far as one would want/need. Does anyone have any thoughts? ...

Why isn't this JavaScript executed?

I was actually not going to, and am afraid of asking such a silly question, but i have completely no clue what is going wrong here. My JavaScript function ahah(url, target) { document.getElementById(container).innerHTML = ' Fetching data...'; if (window.XMLHttpRequest) { req = new XMLHttpRequest(); } else if (window.ActiveXO...

Google Maps directions text format

Ive noticed that sometimes gmaps directions display a turn like this: Turn right at Gallardo and sometimes like this: Take the 1st left onto Arregui I need to always see the 1st,2nd,.. like in the second example. Is there a way to receive directions in this format always?. Thanks. ...

How to create and submit a form using Java Script

I'm writing a Firefox extension that's to be used in house. Basically, I need to submit a pdf file and some text values to a web service. Right now I have a html page that does this. I need the extension to automate the gathering and submission of the data to the web service. Here's the html that works. <body> <form name="frm_upload_fi...

How does google maps print work?

Even without a "printer-friendly" view to print directions, when I choose "File->Print" in my browser, the page is formatted differently than the original view. How does Google achieve this? Is it a special javascript facade? ...

Changing IMG SRC with Javascript

I'm new at javascript and while there are many more complex solutions, I don't understand them and hope I don't have to at this point. I have a main picture... <img src="main-picture.jpg" name="Mainpic" id="image"> ...and I want to be able to change this picture when I click on one of two thumbnails. <a href="" onclick="FirstPic()">...

How to add private variable to this Javascript object literal snippet?

Found this at MDC but how if I'd wanted to add a private variable to the var dataset = { tables:{ customers:{ cols:[ /*here*/ ], rows:[ /*here*/ ] }, orders:{ cols:[ /*here*/ ], rows:[ /*here*/ ] } }, relations:{ 0:{ parent:'c...

Javascript replace function won't remove the string

I have no idea why this doesn't work, but doing some validation functions and trying to output a dynamic message to an alert when they hit submit and forgot to fill out a field. It works only on the second click of the submit button, as far as removing the string, everything else works when it should. Here's the code: var fname = $('#f...

ASP.NET and JavaScript dynamic show/hide based on other form fields

I seem to keep running into these complex show/hide scenarios in ASP.NET web forms where the logic goes "if Field A equals blah, and Field B equals blahblah, then Field C is shown/hidden/validated/whatever." Before I run off and start building custom validators and custom controls so I can more easily manage it in markup or backend code,...