views:

58

answers:

2

I'm starting to write code using Prototype coming from a jQuery background. Is there any chart that shows the prototype equivalent method to use in place of specific jQuery methods?

More specifically, I'm looking for a $('#my-id').prepend('some stuff') equivalent in prototype?

+1  A: 

i can't comment (which is really wot this is) on this cos i don't seem to have enough pips, but even tho rOr comes out of the box with a big affection for prototype -i threw it all away for jquery -do you have a very good reason for abandoning jquery?? alternatively there's always mootools =)

violet313
I abandoned jQuery because I switched jobs and have to pick up the new job's frameworks of choice.
Craig Gardner
+1  A: 

Other folks here will know much more about prototypejs than I, but here's a prototypejs/javascript hybrid. Who knows, maybe this is how its done.

var $elem = $('my-id');

var newNode = document.createTextNode('some text')

$elem.insertBefore(newNode, $elem.firstChild);

Something tells me that prototypejs must have some easier way of creating text nodes, and/or prepending them.


EDIT:

I think I figured it out:

var $elem = $('my-id');  // Get element with ID 'my-id'

$elem.insert({top:'someText'} );  // insert 'someText' at top position in $elem

http://www.prototypejs.org/api/element/insert

patrick dw