javascript-objects

GWT JavaScriptObject reading "delete" property

I have the following native method in a extended JavaScriptObject class: public final native boolean getDelete() /*-{ return this.delete; }-*/; but this apparently doesn't work as "delete" is an javascript operator. How can I read this property correctly. The thrown exception is: com.google.gwt.dev.js.JsParserException: missing n...

JavaScript: Convert string to value of predefined variable

I have a JavaScript object that looks like the following: venue = function(map, dataSet) { // set some constants this.VENUE_ID = 0; this.VENUE_NAME = 1; this.VENUE_CITY = 2; this.filterBy = function(field, value) { ... var filterValue = 'parent.VENUE_' + field; } } Now, the problem is that I ne...

Is it possible to use a variable to call an object who's name is the same as the variables value?

Let's say I have a function which is being passed a string which originally came from getElementById, and I have an object with the same name as that string's value, is there a way to call that object? I won't know which object I want until I get that value from the element's ID. For Instance: StartingFunction(SomeID){ someVariable = d...

JavaScript mechanism for holding onto a value from a user action

I've created a JavaScript object to hold onto a value set by a user checking a checbox in a ColorBox. I am relatively new to jQuery and programming JavaScript "the right way" and wanted to be sure that the below mechanism for capturing the users check action was a best practice for JavaScript in general. Further, since I am employing jQ...

javascript document height complications

Mozilla & IE developers seem to have simultaneously changed the implementation of their height elements to represent the Opera implementation... which I previously did not have to worry about. var height = (document.height !== undefined) ? document.height : document.body.offsetHeight; When performed on a blank document now returns 0 as...

Packing tree into array in Javascript

Ok, so this shouldn't be difficult, however I have encountered weird and bizarra flukes. I am trying to pack a tree into an array, where each node is something like: title: string-for-display key: id-value children: array of child nodes the fluke is so strange I can't comprehend it at all: when I try to add a child to a node, I do...

Creating New Objects in JavaScript

I'm a relatively newbie to object oriented programming in JavaScript, and I'm unsure of the "best" way to define and use objects in JavaScript. I've seen the "canonical" way to define objects and instantiate a new instance, as shown below. function myObjectType(property1, propterty2) { this.property1 = property1, this.property2...

JS: Object itteration fails

Hello! In my JS, I have an object called box_object. It looks like this: ({ id:"3", text:"this is a box object", connection_parent:["1", "2"], connection_child:["5", "6"], connectiondata_child:{ 0:{id:"5", linepoint:"bottom"}, 1:{id:"6", linepoint:"bottom"}}, connectiondata_parent:{ 0:{id:"1"...

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 ...

Accessing javascript object reference.

Ok, Im wondering if it is possible to transfer the reference of the object to the functions. If you dont understand what im trying to say, this might help: //so i declare the variable `Editor` var Editor = new (function(e, d){ this.edit = e; this.dyna = d; this.old = ""; //and set these variables inside the object this....

Changing an Object's Type in JavaScript

I have an array of existing object defined with JSON. The objects are obviously of the Object type. How do I associate them with a custom object type to give them specific functionality? ...

Object property always undefined

This is the first time I've used JS objects and I'm confused as to why this property is always undefined: function Rotator() { this.interval = 300; this.image = 0; this.images = undefined; } Rotator.prototype.Fetch = function(links) { console.log("Fetch called"); this.images = links; } Rotator.prototype.Current = f...

chrome re-ordering object keys if numerics, is that normal/expected

i noticed that certain code that evaluates some shoe sizes JSON for an e-commerce site and outputs them on screen is messing up the order in chrome. the JOSN string given can be: {"7":["9149","9139","10455","17208"],"7.5":["9140","9150","10456","17209"],"8":["2684","9141","10457","17210"],"8.5":["9142","10444","10458","17211"],"9":["26...

jqGrid dynamic select fields

Hi, is there a way to modify the values of a status field in the colModel dynamically? Lets say we have a col Model with a field like: ... field ... name: "state",type: "select", editoptions: {value: "0:state0;1:state1;2:state2;3:state3;4:state4"} So I get a select field for my states with this values. But I need to dynamicaly decide...

javascript var returning object Object when should be returning an int or string

I have two ajax functions and use the first one to pass some data to the second however when I look at the POST, I see that for the variable I am being sent I am getting object Object returned as the value of the variable and not what I was expecting either a string or an int. The javascript looks like this, $('.career_select .sele...

Calling one method from another in JS

I have the following snippet of JS var Customer : function() { this.ShipProduct : function() { //Logic for shipping product. If shipping successful, notify user //Here I am trying to call Notify //this.Notify(); // does not work } this.Notify = function() { //Logic for notify } } How...

Is there a better method than setting a variable to this?

In my javascript objects i found myself writing this: this_object = this; It seems it's the only way to pass member variables to external functions... google.maps.event.addListener(this.marker, 'click', function() { this.info_window.setContent('Chicago marker'); this.info_window.open(this.map,this.marker); }); That doesn't ...

What is the behavior of typing {a:1} giving 1, and {a:1, b:2} giving an error in a Javascript console?

The following will show in Firebug or in jsconsole.com or in other Javascript interactive console: >>> foo = { a : 1, b : 2.2 } Object { a=1, more...} >>> foo.a 1 >>> foo.b 2.2 >>> { a : 1, b : 2.2 } SyntaxError: invalid label { message="invalid label", more...} >>> { a : 1 } 1 why is the 1 returning for {a : 1} and why is {a : 1,...

Deleting javascript object instances

Hi all, I use spryvalidation in my forms, a situation comes when i create input elements dynamically which then create the validation instances dynamically. the problem comes when a user tries to delete an input element...the javascript object still remains. how can i delete the object dynamically on client side or in short how can one ...