Mk 27 wrote:
> Marnen Laibow-Koser wrote:
> 
>> In sum, then...please don't tell me what I say is "patently ridiculous" 
> 
> It still seems to me that it is.  Where there is html, there can be 
> javascript.  

Yes.  There can also be CSS.  There *should* be neither.

> I would far rather use one line
> 
> <script type="text/javascript>create_menu_div(some parameters)</script>
> 
> Than cut and paste the 20-50 lines of html this could represent, esp. 
> since it will allow the use of DOM*.

Apparently you don't understand what I'm getting at here.  I'm not 
talking about cutting and pasting HTML as an alternative to inline JS 
(although that's trivial with a partial or a helper, which should be 
your first choices if all you need is repeating elements).

Rather what I'm talking about is simply having <div class="menu"></div> 
in your HTML, then do something like

window.onload = function () {
  $$('.menu').each(function (div) {
    createMenuDiv(e);
  };
};

in the separate JS file.  Much cleaner; much better separation of 
presentation and behavior.  Almost (M)VCish -- the JS is sort of the 
client-side controller.

> Also, using an event handler still 
> entails putting some javascript in an html page somewhere.

Not necessarily.  You can use the onload technique (as above) to assign 
behavior without a single JS call in the HTML.  All you need is the 
external <script> tag in the <head>.

> 
> You have hit a paradox by saying that you want to use prototype, etc. 
> but you do not want to see any js calls in your html files. 

It's not a paradox at all.  It's perfectly feasible, and I know because 
I have done it.

> I do 
> understand it is an explicit goal of rails to minimize the amount of js 
> that the developer has to deal with personally, but I am already 
> comfortable with it.  

So am I -- comfortable enough to know that I don't like Rails' approach 
that much (although I do use it here and there for simplicity's sake).

> I could tie my left hand to the chair in order to 
> guarantee that only my right hand will be used for typing, but why 
> bother?

I'm really not impressed by the analogy.  Properly separated JS is a 
little harder to set up initially, but is much easier to deal with 
later.  Come to think of it, the same could be said of frameworks such 
as Rails...

> 
> Anyway, Marnen, these are *cosmetic* preferences.   I would just hate to 
> see the day when some weirdo consortium comes along and says "From now 
> on, everyone must tie their left hand to the chair", altho I doubt that 
> will be possible in this case.

Again: it is possible.  It is feasible. It's not even particularly 
difficult.  I have done it on a complex application, and would do it 
again in similar circumstances.  It is not a cosmetic preference, but 
rather an architectural one.  And it is not my idea alone -- it comes 
from the JS guidelines of Douglas Crockford ( http://www.crockford.com 
), who is or was a JS architect at Yahoo! (he's also the guy who 
discovered JSON and the classical inheritance patterns in JS).  If 
you're working with JS, I strongly recommend poking around his site if 
you haven't already -- there's lots of useful stuff.

> *meaning there may be more unfortunate use of javascript still to come 
> :O

Well, yeah...

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
[email protected]

-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to