javascript

jquery .attr() class switch not working....

Hello, I'm working on a web service, when the user requests more data through ajax, I want the div that will contain the data to show a loading circle. I wrote a css class in the style file for when I want the circle: .ajax_getTeams_loading{ background: url('ajax-loader.gif') no-repeat center center; } So my ajax function is like...

Replace is not defined, but why?

Hi, can somebody tell me what is wrong? JS Code $.ajax({ url:"http://www.google.com/complete/search?qu=chicken", success:function(data){ var test_data = ''+data+''; // convert object to a string $('body').append(typeof(test_data)); var test_data = replace.test_data(/[0-9]/,'X'); $('body').appen...

Why store a function in a variable?

Possible Duplicate: Javascript: var functionName = function() {} vs function functionName() {} Every now and again I see examples of JS code where an anonymous function is stored in a variable: var foo = function() { some expression } What does this let me do that function foo() { some expression } can't accomplish? ...

Resize a canvas image on click and center that with javascript

How is it possible to zoom a photo contained in a <canvas> tag? In particular I'd like to zoom in on the photo at the point the user clicked. The zoom is not difficult to do: img.width = img.width + 100; img.height = img.height + 100; ctx.drawImage(img,0,0,img.width,img.height); The problem is that I would also like to center the zoo...

Jquery sliders behaves differently than example from documentation.

I copy pasted the code from http://jqueryui.com/demos/slider/range.html for local testing. And what I see is different from what the url shows. When I click the slider "big dots" (used to change the value) the dot image gets a dotted border around it and it doesn't go away after I release the click until I focus another element on the pa...

Javascript in Internet Explorer : How to do something after a variable is loaded/registered..

Hey everyone, I'm using some jQuery that works fine in all browsers except in Internet Explorer 8 (and probably not the earlier versions although I'm not as worried about those.). I'm using jQuery's .each function to loop over every element in a JavaScript array that is auto generated on my page by the fairly inflexible CMS I'm using. ...

Add/Remove items from one ListBox control to another ListBox control in ASP.NET from the client-side

I'm moving itmes from one ASP.NET ListBox control to another ListBox control from client-side. It works on the client-side but when I tried to count items in destination ListBox on the server-side, it's always nothing. Below, is the jQuery code used to add/remove items from ListBox control. <script type="text/javascript"> $(document...

In node.js javascript why can't I add to a child function?

game_state = function(){ this.players = function() { this.x = 0; }; } game_state.players['test'] = 1; Why does this fail but game_state['test'] = 1; does not? I'm trying this in node.js in case it wasn't clear. Thanks for any help. ...

how to tell if a property exists and is false

I am having a hard time determining if data passed into the jquery template exists and is false without getting errors. This is what I am using to test <html> <head> <title>jQuery Templates {{if}} logic</title> </head> <body> <p id="results"></p> <p>How do you test if the Value exists and is false?</p> <script id="testTemplate" type="...

How to reposition CSS-hover popups to stay within a fixed frame?

I have a page filled with many fixed-size boxes in a grid layout (div's simply piled up with float:left). On hovering the mouse on any of them, a 'popup' - larger div with the same and also additional info is shown over it, as if the box expanded in all directions (but not moving the other boxes, it's shown also over them). Simplified ht...

Calling a Winform hosted WCF service from javascript

I have a Winform hosted WCF service with Ajax Web endpoint. I also have an ASP.NET project separately, with ScriptManager component on the page. My question is, should that work if I make service calls to my Winform hosted service from the client side of ASP.NET app using javascript? My ASP.NET Default page looks like this: <scrip...

All Javascript Commands for URL's

So I want a list of all javascript commands what can manipulate or get information about URL's. Example: window.location.href ...

the javascript object model: strange constructor property

I find the behaviour of this piece of code puzzling, why is the constructor of child not Child? Can someone please explain this to me? function Parent() { this.prop1 = "value1"; this.prop2 = "value2"; } function Child() { this.prop1 = "value1b"; this.prop3 = "value3"; } Child.prototype = new Parent(); var child = new C...

Why doesn't ASP.NET (3.5) always load an external javascript?

I have an external JavaScript in an asp.net 3.5 project. While writing different functions, sometimes the JavaScript is loaded into FF and sometimes it is not (based on FireBug) and the JavaScript does not run. Even if there is an error in the JS it should still load or be visible to the browser, right? What is the logic behind when i...

Swapping a character for another in Regex/Javascript

I'm looking to do something like: var a = "This is an A B pattern: ABABA"; a.replace("A", "B"); a.replace("B", "A"); and have it return: => "This is an B A pattern: BABAB" instead of: => "This is an A A pattern: AAAAA" My first thought is to do something like: a.replace("A", "improbablePattern"); a.replace("B",...

resources for learning 3D basics (Python / JavaScript)

While I consider myself a reasonably competent programmer, I have no experience with even the most basic graphics programming. Are there any recommended resources for learning the basics of 3D programming - preferably using a high-level language like Python or JavaScript? Ideally, I'd like a simple hello world example in canvas or WebG...

How do I add an external javascript file and run a function via bookmarklet?

Hi I'm trying to make a javascript bookmarklet that will add a link to an external javascript source to a page that is off the domain. However nothing happens when I run the bookmarklet no errors and the code on the page never changes. Any ideas? Here is the bookmarklet I'm trying to use. Thanks for your time. javascript:(function(){do...

server to client push?

I keep getting comet when I search for this, but comet seems to complex for my needs, i.e. 100 users max with probably 10 users online at a time. Is there are better solution for my requirements, i.e. be able to push data to clients, probably between 10-20 clients max at a time. ...

What's the best abbreviation of this jQuery instruction?

$( "input[role=submit_action], button[role=submit_action], div[role=submit_action], span[role=submit_action], a[role=submit_action]").live( "click", function() { }); and this too: $( "input[role=submit_action], input[role=submit_require]").live( "click", function() { if ($(this).attr('role') == "submit_action") { // ...

Comet for not-so-frequent events

Is it worth using Comet for events that are not needed "in realtime", but with a possible delay of, say, 1 minute. Such would be: twitter status updates facebook updates I know comet is perfect for a chat application (facebook and GTalk chats are using it), but does twitter, for example, use comet. Or is AJAX-polling sufficient for ...