Marnen Laibow-Koser wrote:
>> The <head> I would say is part of an html page.
>
> Yes. That's not what I meant. Rather, I meant that the <script> tag
> points to an external file, so there is *not a single line of JS* in the
> HTML file.
Alright, I'll think about it. I have probably written <1000 lines of
.js in my life*, no doubt there are angles and possibilities I am not
aware of.
Here is an example callback for the menU_div_create function I
mentioned, if this will clarify with the crude "switch" mechanism:
function mainmenu (num) { switch (num) {
case 0: if (!DBname) { alert("You must create a new database
first!"); break; }
var tmp=prompt("Record name:");
new ListRecord(tmp); break;
case 1: if (current==-1) { alert("No record selected!"); break;
}
var tmp=prompt("Field name:");
new formDBentry(tmp,undefined); break;
case 2: submit_form(); break;
case 3: window.open("mkdb_load.pl","_self"); break;
case 4: tmp=prompt("Database name:");
if (tmp == "") break;
DBname=tmp;
clear_start();
default: break; }
}
the array corresponding to this (5 options that are the text for the
menu):
var mmenu=["Add Record", "Add Field", "Save", "Load", "New"];
and here is the "real" make_menu function, it does not actually involve
a div; but usually the "parnt" is (and "callback" is the function
above):
/* make_menu is not real OO */
function make_menu (type, css, choices, callback, parnt) {
var i=0;
var tmp, strng;
do { tmp=document.createElement(type);
tmp.setAttribute("class",css);
strng=callback+"("+i+")";
tmp.setAttribute("onclick",strng);
tmp.textContent=choices[i];
parnt.appendChild(tmp);
i++; } while (choices[i]);
}
I haven't used this in rails, but I am using js functions that to my
mind are similar in the sense that I do not see a way out of inlining
them. Hopefully, in time I will learn.
*but I am still snobbish coming from "the real languages" ;)
--
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
-~----------~----~----~----~------~----~------~--~---