javascript

jQuery: When getting the value of an element, do I need to declare the variable in document ready?

I'm storing the value of a specific form element as a variable. This same value is used in multiple functions. function one() { var selectedRole = $('#RegistrationRole_ID').val(); } function two() { var selectedRole = $('#RegistrationRole_ID').val(); } I'd like to make this a global variable so I don't have to keep selecting i...

Javacript Calling Into Silverlight for Webcam Capture

I have a rather unique situation here. I have a Silverlight application that captures images and uploads them to a web server which is pretty standard, but a requirement I have is to allow the web designer to make their own buttons and controls (or to style them) that controls the application. So I decided to use ScriptableMember functi...

jQuery vs CSS Preferred or Accepted Style Best Practices

I have the following loading image: <img id="loading" src="loading.gif" /> To show/hide it during an AJAX call, I have several solutions. For example, I can hide it by adding a class which corresponds to a CSS style: $('#loading').addClass('hidden'); .hidden { display: none; } Alternatively, I can use jQuery .show() and .hide(). I...

Is it better to have one large object in JavaScript or many smaller ones?

I'm writing a JS lib that reads chess games to turn them into re playable games, in one single web page there can be many games (one in its own div), what I'm wondering is – thinking about performance – if it's better to have one large object that holds all the moves of all the games or many smaller objects each storing the moves of one ...

So confused about why vars work sometimes with or without var?

I am really confused as to why sometimes vars will not work when "var" is declared in front of them when used in a namespaced object. Isn't adding "var" in front of every variable the correct thing to do to keep it outside the global namespace? Or would creating any var without declaring "var" first in my namespaced object, ensure of th...

Where is Permission Denied Location.toString occurring

I am getting an error when my app is being embedded in an iframe that reads Permission denied for https://myapp.com to call method Location.toString on http://otherhost.com I am not getting a stack trace, line number, or file where this occurring in any of the browsers. How could I figure out where this problem is coming from? ...

jQuery Cycle Plugin callback error

I can't get before & after callbacks to work with the cycle plugin for jQuery! I'm not sure what's going wrong, i even tried using the sample code from the documentation. Here's the code: $(document).ready(function(){ function onBefore() { alert('before'); } $('.slideshow').cycle({ before: 'onBefore' }); }); a...

ASP.NET AJAX UpdatePanel - cancelling postback in InitializeRequest will not set back to re-enabled.

Within an ASP.NET AJAX UpdatePanel on my page I have a submit button which has some custom javascript validation applied which set a global _cancelGeneralSettingsUpdate flag depending on the results of the validation. Everything works unless you enter an invalid value, correct it, and resubmit. In this case the variable _cancelGeneralS...

Share variables between modules in Javascript/node.js?

I have 3 node files: // run.js require('./configurations/modules'); require('./configurations/application'); // modules.js var express = module.exports.express = require('express'); var app = module.exports.app = express.createServer(); // app.js app.configure(...) Run.js requires both files, modules.js which require a module and...

How to create a Google Reader ??

I need to create a web tool like Google Reader for my college project. I have 2 question about it: 1) How Google Reader track the read and unread posts ? 2) Google Reader save every post in the db or load the feeds at the moment ? ...

What IDE to use for Node.js / Javascript?

What is your preference when it comes to editing/debugging large JavaScript projects, containing number of relatively big JS files? Please list your choice, why do you like it compared to others; If it is already listed you can up vote it if you like. ...

Javascript mess, help for jquery-(PHP/jQuery) Desktop app

Hi, First of all, im new here, and im (not) a pro ;) (but i want to... lol). Okay, im starting a little php application to manage my icons (huge) collection... but i realise that i wrote everything in javascript (no jQuery) and my life would by a little more easier if i use jQuery... So now im trying to understand how to do that i i'll n...

How can I use JSLint for a segment of code which depends on JQuery?

I'm relatively new to Javascript, and I'd like to run the piece of code I spent the weekend playing with through JSLint so that it can point out where I was being a total idiot :) Unfortunately, I get tons of errors about missing function declarations, which are part of the JQuery javascript library and various plugins for it. Is there...

Invoke javascript function cross domain, don't expect a return value

I want to invoke a javascript function, and I don't need a return value. The function is provided by a flash externalinterface, but I don't have access to allowing my domain access... Can I proxy a javascript invocation? Do I have to send a cloned post, or is it possible to simply call the function? I know YUI has callSWF, can I use th...

RegExp.exec not returning global results

According to MDC https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/RegExp/exec the following code should log each of the global matches for this regexp. var str = "(^|\\+)(1\\+1)($|\\+)"; var regex = new RegExp(str, "g"); var result; var testString = "1+1+1"; while ((result = regex.exec(testString)) != null) { con...

jquery - write a function to allow for a callback?

Possible Duplicate: Javascript callback programming? A lot of jquery functions allow for a callback. Most are in a syntax like: $('.selector').slideUp('fast', function(){ alert('slideUp has completed'); }); If I'm writing my own function, how can I make sure it is finished before the one after it is called (i.e. provide...

How do I redefine `this` in Javascript?

I have a function which is a JQuery event handler. Because it is a JQuery event handler, it uses the this variable to refer to the object on which it is invoked (as is normal for that library). Unfortunately, I need to manually call that method at this point. How do I make this inside the called function behave as if it were called from...

extend properties in javascript

hi, i have this code in javascript: var object = { get: function(id){ sel = document.getElementById(id); sel.orig = {}; ... return object.extend(sel, object); } extend: function(el, opt){ for(var name in opt) el[name] = opt[name]; return el; } } and in another js i hav...

jQuery selector "memory"

I have a form with multiple fields, and each time the user changes a field the form is submitted (via hidden iframe), and the response is placed within an appropriate div on the page via a callback. The first time this works fine. But on each subsequent field change and submission, the response is shown in every div that has been filled ...

How to pass JS variable to php?

I have a javascript functions which returns a hash. I need to pass this hash to php to do stuff with it. Whats the best way to do that? ...