In JavaScript, if I have a string in a variable, is there a way to get a reference to the function object which has that matching name? Note that jQuery is ... |
So I have a class foo that has a method which returns an array bar. I have another function that calls foo.getBar and then filters the array. I want to be ... |
Possible Duplicate:
Can Read-Only Properties be Implemented in Pure JavaScript?
I have an Object that I only want to be defined when constructed. How can I ... |
I currently have a Javascript function that uses a string to reference an object name and acces its properties. I'm currently using eval() to get the the desired effect which I ... |
As far as i can see in a situation like this:
var x = [];
var y = {};
y.someProp='asd';
This doesnt work:
x.push(y);
What I want to do is add a reference of y to x ... |
I've got the following function that manipulates an element according to the data being sent (an object).
function manipulateElem (elem, data) {
for (var key in data) {
...
|
I'm using the date.js library.
Previous code:
alert(incidentDate);
var deadlineDate = incidentDate;
deadlineDate.add(2).years();
alert(incidentDate);
return;
Adding to the deadlineDate caused the incidentDate to change too. A bit of reading revealed that this was because objects in javascript are ... |
|
I'm trying to replicate a "feature" of PHP (And in most languages) in Javascript.
Here it is in PHP:
$objectName = 'ObjectA';
$someObject->$objectName->someMethod();
Basically using a string variable to reference an object variable.
So in Javascript, ... |
I'm using JavaScript Mapping Library - OpenLayer to create a markers overlay.
I want to control the markers dynamically: add new ones and remove existing markers from the layer.
the way to add ... |
In the plupload (plupload.html5.js), I see this code:
// Blob is string so we need to fake chunking, this is not
// ideal since the whole file is loaded into memory
if (typeof(blob) == ...
|
say I have
myfunc({
var1: 1,
var2: 2,
})
if i want to have a value that makes use of the current unnamed object, how would I do this?
eg if I wanted
myfunc({
...
|
I have several objects on a page... I know the name of one of the objects and it's stored in a variable called editorId. How can I access that object's methods? ... |
I am try to use a controller to wrap my page's logic, based on the idea of this article, but I met some problem when using literal object defination ... |
I have the following struct (or class?) in JavaScript:
function ImageStruct() {
this.id = -1;
this.isCover = true;
this.isPaired = false;
...
|
Given a JS Object: var obj = { a: { b: '1', c: '2' } } and a string 'a.b' how can I convert the string to dot notation so I ... |
Given data similar to:
var data = [{id: 12345,
name:'my products',
items:[{
...
|
var string = 'object.data.path';
That's a string that resembles a path to variable.
How can I return the corresponding variable from that string?
Something like transforming the string into return object.data.path;
The thing behind this ...
|
I want to create a new instance of an object every time I click a button on my page. The problem is the reference variable, if you look at this example?
<input ...
|
I have a javascript objects var flower_1; var flower_2;
My question is if I have another variable for example a String var Name;
And lets say for example: Name = "flower_1";
How can ... |
|
|
Is it possible to test whether two objects are equal using the data they contain inside and not comparing their pointers with ==? Well actually of course there is but... Is there a way to do it without actually looping through the object, instead maybe something that came with JS? (something like a .equals() method from other programming languages.) Thanks for ... |
Original - javascript Code function Referrals ( id ) { this.get = "/getReferrals.php"; this.JSON; // (Array) returned from initial AJAX request this.save = ""; this.formData ( id ); } Referrals.prototype.formData = function ( id ) { var pars = 'refid='+id; this.createForm ( id ); var ajax = new Ajax.Request(this.get, {parameters: pars, onComplete: this.populateForm } ); } Referrals.prototype.populateForm = function ( oReq, ... |
|
Passing and using variables in object references I am trying to make a function that checks/unchecks a checkbox when a specific is clicked. I need to use this same function for several checkboxes in the page so I want to just pass it the name of the checkbox I want to affect as a variable and use it in the ... | |