This project is archived and is in readonly mode.

#1276 ✓invalid
DAddYE

RJS & C.

Reported by DAddYE | October 27th, 2008 @ 11:27 AM | in 2.x

Hello,

I want report a suggestion.

Now rails is great because in one framework we have all!

Most of us don't like prototype, rjs & c.

In my opinion we can make the easy use of rails with ajax in a unobtrusive way.

See that:

Helpers: The most usefull helper are link_to_remote, form_remote etc... but in my opinion make the html code very unclean:

Why do some like this?


<a href="#" onclick="new Ajax.Updater({success:'posts',failure:'error'}, '/blog/destroy/5',
{asynchronous:true, evalScripts:true}); return false;">Delete this post</a>

in favor of:


<a href="'/blog/destroy/5" onclick="linkToRemote('/blog/destroy/5');">Delete this post</a>

Then you can easy make a /adapter.js (yes the template can be in prototype) with all ajax functions that are used by prototype/scriptaculus helpers like:



function linkToRemote(url){
new Ajax.Updater({success:'posts',failure:'error'}, url, ...
}

So we can rename this two modules in AjaxHelper/EffectsHelper...

In this way, rails can be bundled with prototype and for a lot of newbie users still happy without any problem with this change. But for the most users that love jquery, mootools, extjs can simply change their adapter.js and use all beautifull ajax/effects helpers without install some (good) plugins like jRails and edit by hand all helpers.

Views: Now if we make an ajax request mime: text/javascripts rails look for rjs template.

Ive see very very few project that use it and I don't know any person that love and use rjs templates, because are limited and are not a standard... Why don't remove rjs in favor of a simply js.erb template?

In controllers we can still use some like:


  render :js do |page|
    page.replace_html ...
  end

and in our adapter.js


function replaceHtml(id, text){
 new Element.update(id, text);
}

(Im not sure that the prototype syntax are correct :D)

also why this?:


render :update do |page|
  page << "alert('test')"
end

and not:


render :js => "alert('test')"

I know there is format.js, but all this small changes for people that don't use prototype complicate the life

I think you can follow my suggestion, rails still easy for prototype users, but very very flexible for people that need some different js frameworks. And in my opinion can be a standard.

Think in future when people can do this:


 rails myapp --js prototype/jquery/mootools

One more thing, like merb, why insert haml as choice of developper integrated in rails?


  rails myapp --template erb/haml

Thanks

Comments and changes to this ticket

  • DHH

    DHH October 30th, 2008 @ 10:50 AM

    • State changed from “new” to “invalid”

    We don't use Lighthouse to track feature request. If you want to implement any of this, please do go ahead and create a patch ticket when you have something running.

    But be aware that your circle of friends not liking RJS is not representative for the entire Rails community. And that as a feature it's entirely optional. You're more than free to have action.erb.js templates.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Pages