How to unwrap $() / get native object?

a place to get help

Moderator: 1.1 Moderators

How to unwrap $() / get native object?

Postby xrmb on Fri Jan 29, 2010 5:10 pm

I'm picking up a bunch of select's via $$, then I want to clean them all by using the selects remove function... well I can't because mootools overloads its own remove function, completely hiding the remove function.

So is there a way to get the unwrapped object?

(Do you know what I'm talking about?)
xrmb
 
Posts: 4
Joined: Fri Jan 29, 2010 5:04 pm

Re: How to unwrap $() / get native object?

Postby daKmoR on Sat Jan 30, 2010 12:07 pm

unwrapped object?

no glue...

maybe you mean the native DOM element not extended with MooTools functionality (trough $) - but why the hell would you like to have this?
"Speak when you are angry and you will make the best speech you will ever regret." - Ambrose Bierce
User avatar
daKmoR
Site Admin
 
Posts: 860
Joined: Mon Jul 14, 2008 11:40 am

Re: How to unwrap $() / get native object?

Postby xrmb on Sat Jan 30, 2010 1:27 pm

yes, the native DOM-object.

And the reason... a $E('select.mine') returns a "wrapped" select box, but I cant use the native .remove function to remove options, because mootools overloads it with one for removing the whole element. Mootools 1.2 doesnt have that problem since they got rid of the overloaded remove, but I'm stuck with 1.11 for now.
xrmb
 
Posts: 4
Joined: Fri Jan 29, 2010 5:04 pm

Re: How to unwrap $() / get native object?

Postby wowenkho on Sat Jan 30, 2010 1:54 pm

i think the issue is not necessarily getting the source element before it got enhanced by MooTools. it's more of finding a way to know how you can emulate the original purpose of remove() in vanilla JS with any of the available functions in MooTools 1.1.
my sword is yours...
http://wowenkho.com

for those who want to talk with me quicker, add me on Yahoo! Messenger through my ID: michaelapeles
User avatar
wowenkho
mootools freak
 
Posts: 1146
Joined: Sat Aug 15, 2009 10:38 am
Location: Antipolo City, Philippines

Re: How to unwrap $() / get native object?

Postby xrmb on Sat Jan 30, 2010 8:33 pm

emulating the original remove function is fairly easy, but I pass it to one of my framework functions... which I know have to modify. I was hopping there is something like in Greasemonkey... object.wrappedJSObject. Oh well, there might be no solution, except going to v1.2 ;)
xrmb
 
Posts: 4
Joined: Fri Jan 29, 2010 5:04 pm

Re: How to unwrap $() / get native object?

Postby dudeinmo on Mon Feb 22, 2010 7:51 pm

If your wanting to remove an option in a select use the following

$('select.mine').options[i] = null;


replace the select.mine with the id of your select object and the i in the brackets with the number of the option is.

Here is an example on jsfiddle ..... http://jsfiddle.net/drkua/

If you hit run, then check out the colors you'll notice the Royal object is there, when you select Long Sleeves though ... it goes away, but you can't get it back without recreating it, it is totally removed from the dom until a refresh.

Is this what you where trying to accomplish?
"You have to be the change you want to see in the world" - Ghandi
Rob Crowder Designs ( My Site )
MooTools 1.11 Docs
MooTools 1.11 Demos
User avatar
dudeinmo
 
Posts: 10
Joined: Wed Jan 27, 2010 6:56 pm
Location: Sugar Creek, MO

Re: How to unwrap $() / get native object?

Postby xrmb on Mon Feb 22, 2010 9:21 pm

Thats what I'm doing now. I kissed the .remove() function good-bye, although it seems the DOM preferred way for removing options... well, until you want you use .add() and IE messes it all up.
xrmb
 
Posts: 4
Joined: Fri Jan 29, 2010 5:04 pm


Return to Help

Who is online

Users browsing this forum: No registered users and 1 guest