javascript-functions

JavaScript function name as a string...

Hi, I have the name of a function in JavaScript as a string, how do I convert that into a function pointer so I can call it later? Depending on the circumstances I may need to pass various arguments into the method too... EDIT I should note that some of the functions may take the form of namespace.namespace.function(args[...]);... ...

Problems calling jQuery function from within normal JavaScript function

Hi. Tried looking at other solutions but they don't quite answer my question so here goes. The code below shows me declaring an anonymous function to run when the document is ready which contains another function relating to a plugin which creates a horrizontal accordion. That function takes in certain properties and one property, even...

Probably obvious problem in JavaScript

Hi, I think this is just an obvious problem that I can't spot because I've been staring at code too long today. I have this callback as part of a JQuery POST: function(data){ if(data == 'yes') { $('div.done').show(); ...

How to check/calculate the week-day count (using Date functions) using Javascript?

Hi, I'm struggling with some javascript and date issues. I would like to check if a given date is the first, second, third, fourth or last monday, tuesday, wednesday,..., sunday in the dates month. The function should look like this: if(checkdate(date, "second", "monday")) { alert("This is the second monday of the month"); } else ...

change global function scope in javascript

Is the following possible: var someObject = {someProperty : "someValue"}; var someFunction = function() { someProperty = "anotherValue"; }; // what do I do here, in order to use // someFunction to change someObject, // without altering either of those things? // directly accessing "someObject" in someFunction // is not an option. e.g...

JavaScript - Settting property on Object in Image load function, property not set once outside function

Sometimes JavaScript doesn't make sense to me, consider the following code that generates a photo mosaic based on x/y tiles. I'm trying to set a .Done property to true once each Mosaic image has been downloaded, but it's always false for some reason, what am I doing wrong? var tileData = []; function generate() { var image = new Im...

Dissapearing object function??

Is there a reason for object functions to be unset or deleted or simply not applied for any reason at all that isn't intentional? I am maintaining someone elses code and gone through it many times. I use Google Chromes awesome debuger and also TextMate. These help me find the origin of error relatively fast. The problem I have now is ...

How to get return data from event handler?

Ok, this is a very simple question. I am actually 90% sure I know the answer, but the late hour is causing me to completely space it. I've searched it on SO and Google to no success. How do I get return data from an event handler function? I have several nests of event handlers, and need to get the result from the deepest out to the ma...

JavaScript/jQuery - "Array" of Arguments - Possible?

Hi Guys, Doing some client-side JavaScript development, which requires me to call a client-side API which only accepts one parameter at a time (cough, cough, facebook). Basically i need to call an API method twice: someFBApi.requestPerms('email') someFBApi.requestPerms('publish_stream') Now, i have a wrapper function for this call w...

Declare javascript function, jQuery

Hi, in my main js file where I put all my jQuery stuff I have following new funcitons: function getDate(){ var currentTime = new Date(); var month = currentTime.getMonth() + 1; var day = currentTime.getDate(); var year = currentTime.getFullYear(); return day"."+month+"."+year; } function getTime(){ var current...

Calling a function inside a function javascript

I have this code inside the success function of a jQuery ajax call success: function(d) for (var n in d.items) { google.maps.event.addListener(markers[d.items[n].id], 'mouseover', function() { focusMarker(d.items[n].id); }); } Unfortunately, the function always evaluated d.items[n].id as the last item in d.item...

problem with callback function in javascript

Hi, I am trying to understand callback functions in javascript. There is a function something like function load() { var func = function(data){ /// }; } Can anyone explain me from where the parameter "data" will be returned, as I dont see any variable declared in the file. ...