Isn't this the kind of thing that the UJS for Rails plugin
(http://ujs4rails.com/) already does?
Cheers,
Nik
--
Nik Wakelin
munky...@gmail.com
I'll probably get in trouble for this, but I don't think that
unobtrusive javascript has yet to obtain the status of undeniable best
practise that you seem to be ascribing to it. The current helpers are
a pragmatic solution to what is otherwise an incredibly frustrating
job, and the code they generate may be 'obtrusive' but it works just
fine.
The specific case you mentioned in your patch sounds interesting but
I'm not sure that the assumption of being able to make non-AJAX to the
ajax url is a valid one. <a href="/people/1"> isn't the same thing as
a link which submits a DELETE request to the same URL.
> Especially those folks new to Rails (and probably not all that
> experienced in web development in general) may be led astray where we
> could easily guide them down the right or at least better way than the
> current one.
What are the current practical problems which the existing helpers cause?
> I'm not saying that Rails should be more newbie-friendly
> - IMO the barriers of entry have already become too low if you take a
> look at the questions asked at RailsForum or WWR.
I strongly disagree with this, while it may be satisfying to feel
superior about people finding it hard to get started, that's not the
way successful communities behave. The barriers to entry should be
*lower* not higher.
--
Cheers
Koz
views dir of project number 1 (irb) :
>> Dir["**/*.rhtml", "**/*.html.erb"].inject(0) { |total, file| total += `grep -c "link_to_remote" #{file}`.to_i; }
=> 29
views dir of project number 2 (irb):
>> Dir["**/*.rhtml", "**/*.html.erb"].inject(0) { |total, file| total += `grep -c "link_to_remote" #{file}`.to_i; }
=> 36
Would seem not everybody feels the same :)
(ps my unix-fu is not strong, so I might have messed those up...)
--
Nik Wakelin
munky...@gmail.com
I just don't think it's something we should be proactive about.
Making the ajax case that much harder to theoretically get
accessibility benefits doesn't seem like something we should be doing.
If there's a way for us to make extend the helpers to make it easier
to add fallback cases, then I'd be happy to hear about those. But if
it's just a question of either:
* Hand Code and be accessible
* use helpers and don't be
Then I think we can just leave the helpers as is and people who feel
strongly about it can start a community talking about how to avoid the
helpers, get some best practises brewing etc.
> As I said earlier, it's not so much about the current functionality
> being a problem but more about the (IMO) better solution standing
> right in front of us and (so far) being ignored.
Given how widely used the current fuctionality is, then we'd need to
see much better adoption of the better solution before we could do
something like this.
If something easier, and more accesible emerges then we can go for it,
but personally I definitely prefer to use link_to_remote over link_to
with some class then inject the ajax functionality onload.
--
Cheers
Koz
There is absoltely no reason/explaination to do so. And I don't see it
happening. Many of us use those helpers in most of the projects, and
it works for us like a charm.
> This would be a wonderful step towards having a Prototype,
> jQuery, MooTools (etc.) package for Rails. The situation with Merb
> and JavaScript is quite wonderful: pick your own and run with it.
> There's no helpers, no RJS equivalent or anything. I like this
> approach personally.
Rails is not forcing you to use those helpers or RJS.
Lack of feature is not a feature. If Rails, in any way, is making it
difficult to implement those helpers/rsj in plugins for other js
libraries, solution is for Rails to provide hooks and make it simpler
to write such plugins. Patches welcome :)
--
Cheers!
- Pratik
http://m.onkey.org
Heh, good point
> - Like I said in the ticket, link_to_remote should populate the href
> by default to provide a sensible fallback.
I'm not sure that this *is* a sensible fallback though, given that it
won't work on resource routes it seems like most new apps wouldn't
benefit even a little from this. The link would go somewhere but not
where it said it would. This sounds more frustrating than just
hitting the #. The documented example seems pretty good in this case?
> - submit_to_remote should be renamed or at least aliased to
> button_to_remote just for the sake of being consistent with link_to/
> link_to_remote.
An alias sounds good.
> - link_to/link_to_remote helpers should at least raise some kind of
> notice when used with :method => :post/:put/:delete. Links shouldn't
> be used to post/put/delete on a server. Yes, I know that it actually
> wraps the whole thing inside a form, but still it's not a good idea.
> The fact that potentially "destructive" actions should be handled with
> a button should definitely be advocated.
>
> - Not strictly related to the helpers: While I think that mostly
> beginners use the scaffold feature, I feel that it still should
> reflect best practices. Therefore, the delete link should be made into
> a button.
I'm not convinced here, while I follow the reasoning that links
should be safe to click, and things which look like links should also
be safe, the pattern is so widely used in our industry I don't think
that putting our collective fingers in the dike will really gain us
much.
--
Cheers
Koz
Sujal
ActionWebService and pagination were unmaintained with better
alternatives out there (REST and will_paginate). acts_as_list was a
close call but each of the other acts was unmaintained and essentially
broken, leaving one in there seemed unreasonable.
auto_complete was a tiny tiny wrapper around scriptaculous
functionality and in_place_editing was too restrictive and tightly
coupled.
Either way, there's no reason to remove those features except for some
ascetic sense of satisfaction which could be drawn. If you don't like
them you can just stop using them. There's no impact with having them
there for applications which don't use them.
--
Cheers
Koz
Pros for keeping helpers: Lots of projects use them
Pros for removing actionwebservice, pagination, etc.: unmaintained,
better alternatives exist (e.g. will_paginate) or can be made easily
(e.g. auto_complete)
The reasons for the proposed patch are "the functionality isn't great"
plus that it promotes accessibility, not just for screen readers but
for things like search engines. That's actually my most important
concern...
It sounds like the opposition is mostly that there isn't an
alternative/better implementation for the js helpers. So, let me ask
a different question: would everyone be more receptive to removing the
javascript helpers if an alternative existed? The UJS plugin was a
decent idea, and the patches attached to the ticket here are not bad
either. Or, is it that removing them is off the table, period? (I can
imagine arguments in favor of having a default JS plugin, but I'm not
convinced by any of them)
Sujal
It would be great to be able to use the JS library that I fancy, but
with the helpers we all love.
regards,
Jan De Poorter
Don't we already have this with things like jrails?
http://ennerchi.com/projects/jrails
If there are hooks or assumptions in our stuff that would make this
kind of plugin easier, then I think we could take patches for that.
--
Cheers
Koz
Methods never called are hardly going to break the bank on performance
or memory usage. There's about a billion other things that should be
higher up your squirm list.
--
Cheers
Koz
Wouldn't this defeat the entire purpose of *not* using a link. The
rationale as I understand it is 'links should be safe to click'. If
it looks like a link, acts like a link, but still isn't safe, then
we're worse off than with the current implementations. It still
surprises people but it depends on crazy css stuff.
--
Cheers
Koz
Try a patch for this and see what people think. It sounds good enough
if the implementation isn't too hairy.
> If you guys agree to this (especially the core team), I'd start
> thinking about that and maybe start implementing it next week. I'd
> totally love if someone else cared to join me in the effort.
I don't think we need to add anything quite that complicated to
actionpack. We bundle prototype and support it with some helpers etc.
Whatever faults prototype may have choosing something is better than
making it a configuration option which needlessly confuses people who
just want an ajax form.
If there's anything which is currently difficult to replace with a
simple plugin, then we can investigate it. But given the good job the
jrails guys have done, I don't think we need anything here.
> IMO that would be a quick win and I'd be happy to implement it as
> well.
I've heard rumours that sam stephenson was thinking around ways to
make those helpers nice and unobtrusive by default. If we can have
unobtrusive code that's just as simple (i.e. one helper call) as the
obtrusive kind, then I say we just go down that path. But again, I'm
not aware of any clear best practise in that space that we could latch
on to.
> - Clemens
> >
>
--
Cheers
Koz