aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Adding and deleting attributes from a javascript object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Adding and deleting attributes from a javascript object" Watch "Adding and deleting attributes from a javascript object" New topic
Author

Adding and deleting attributes from a javascript object

Bryce Martin
Ranch Hand

Joined: Nov 19, 2007
Posts: 269
Right now I create my objects manually based on some condition... Something like this...

if (some condition)
columnModel = [{name:'order',index:'order asc', width:70, align:"center"},{name:'job',index:'job',width:300,align:'right'}]

What I want to be able to do is insert or delete from that object. Is there a way to do this? I want to be able to delete the {name:'job',index'job',width:300,align:'right'} piece if a particular condition is met and add others if other conditions are met...

Am I clear? Is this possible?

Thanks
Bryce
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61612
    
  67

That's not just an object, but an array of objects. Are you talking about removing array entries? You can null them out pretty simply. If you want to manipulate the array further, here's a referecne to array methods. (The splice() method may be what you are looking for).
[ May 19, 2008: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bryce Martin
Ranch Hand

Joined: Nov 19, 2007
Posts: 269
Thanks Bear. I brain farted on this. My coffee didn't work very well this Monday morning (it was a busy weekend with little rest). Thanks for the link. Have a great day.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61612
    
  67

Repeat after me: never post before caffeine, never post before caffeine...
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Adding and deleting attributes from a javascript object