never_had_a_name
never_had_a_name

Reputation: 93196

Arguments for Prototype over jQuery for Rails?

I have never used Prototype before.

But now when I'm using Rails, it seems to me that it doesn't only manipulate the DOM/Ajax but also the language itself.

Example: http://api.prototypejs.org/language/hash/

It was a long time ago I used jQuery, but I recall that the framework didn't have these features right?

Is this a good feature for Rails developers, having the same language convention to on the Javascript side?

Share your thoughts Rails developers!

Upvotes: 0

Views: 177

Answers (2)

Joshua Partogi
Joshua Partogi

Reputation: 16425

The only good reason why developers are using prototype is because there is a prototype and scriptaculous helper which enables you to get away from writing javascript for dom manipulation. But you can always jRails if you want something like prototype and scriptaculous helper. But that argument is quite irrelevant nowadays, especially with Rails 3, because you really want an unobstrusive way to do it.

Other than that, I can not find a compelling reason to use prototype in rails because it's slower and it hacks the javascript native functions.

Upvotes: 1

balupton
balupton

Reputation: 48650

With comparison to other frameworks, jQuery is pretty much just for DOM manipulation. Whereas the others are about providing a framework of objects to your disposal.

The Hash object you mentioned in your question is something which just has the same functionality as any javascript object. MooTools and Prototype like to give them special names (for some good reasons - as extending the Object prototype can cause a lot of code to fall down if you are using for in without a hasownproperty check).

Whether or not one is right for a project is up to you, it's all about preference. MooTools and Prototype are about extending the Javascript language. Whereas jQuery is about creating a super object that has the same features. This is why jQuery has soo many plugins, and why $.fn is used for most of them, instead of working with prototypes - and probably why jQuery is easier for beginners (they don't have to know how javascript works).

Anything you can do in one framework, you can do to another, as there is nothing stopping you from doing it yourself, or sticking something from say MooTools which you like into jQuery.

Upvotes: 1

Related Questions