Forum: Ruby on Rails Pull down menus / Nested Javascripts

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
57d2594584b9c4e2b6fb2059968b3d84?d=identicon&s=25 John Henderson (jh100000)
on 2006-04-18 00:55
Has anyone implemented a tab bar with pull down menus in RoR?
I've tried various javascript solutions but they all fail once you try
to call them from ruby.
Any pointers gratefuly received....
Cheers

John
Ad7805c9fcc1f13efc6ed11251a6c4d2?d=identicon&s=25 Alex Young (Guest)
on 2006-04-18 10:28
(Received via mailing list)
John Henderson wrote:
> Has anyone implemented a tab bar with pull down menus in RoR?
> I've tried various javascript solutions but they all fail once you try
> to call them from ruby.
> Any pointers gratefuly received....
Some failing code would be really useful here.  Since a tab bar in Rails
would be Javascript underneath, it should be possible to make an
existing system work.  It's also not exactly clear what you mean by
'call them from ruby'...
77707eb62b77a12638d1d0a9424afdc9?d=identicon&s=25 Nuno (Guest)
on 2006-04-18 11:22
Alex Young wrote:
> John Henderson wrote:
>> Has anyone implemented a tab bar with pull down menus in RoR?
>> I've tried various javascript solutions but they all fail once you try
>> to call them from ruby.
>> Any pointers gratefuly received....
> Some failing code would be really useful here.  Since a tab bar in Rails
> would be Javascript underneath, it should be possible to make an
> existing system work.  It's also not exactly clear what you mean by
> 'call them from ruby'...

You might have a look here : http://script.spinelz.org/

The menubar is really easy to integrate in Ruby
57d2594584b9c4e2b6fb2059968b3d84?d=identicon&s=25 John Henderson (jh100000)
on 2006-04-18 11:45
Nuno wrote:
> Alex Young wrote:
>> John Henderson wrote:
>>> Has anyone implemented a tab bar with pull down menus in RoR?
>>> I've tried various javascript solutions but they all fail once you try
>>> to call them from ruby.
>>> Any pointers gratefuly received....
>> Some failing code would be really useful here.  Since a tab bar in Rails
>> would be Javascript underneath, it should be possible to make an
>> existing system work.  It's also not exactly clear what you mean by
>> 'call them from ruby'...
>
> You might have a look here : http://script.spinelz.org/
>
> The menubar is really easy to integrate in Ruby

Oh super!  This stuff looks fab.  Can't wait to get home tonight to try
it out.  I see there's all sorts of other good stuff there too like nav
bars, treeviews etc.  I'll let you know how I get on.  Thanks
John
57d2594584b9c4e2b6fb2059968b3d84?d=identicon&s=25 John Henderson (jh100000)
on 2006-04-18 21:30
Alex Young wrote:
> John Henderson wrote:
>> Has anyone implemented a tab bar with pull down menus in RoR?
>> I've tried various javascript solutions but they all fail once you try
>> to call them from ruby.
>> Any pointers gratefuly received....
> Some failing code would be really useful here.  Since a tab bar in Rails
> would be Javascript underneath, it should be possible to make an
> existing system work.  It's also not exactly clear what you mean by
> 'call them from ruby'...

i seem to be narrowing the problem a bit... maybe the question now
should be 'how do you reference an image file from within a javascript
in your ruby project assuming all images are in public/images?'

in the relevant component's view list.rhtml

	<script language="javascript" src="javascripts/tree.js"></script>

tree.js contains:

function Toggle(item) {
   obj=document.getElementById(item);
   visible=(obj.style.display!="none")
   key=document.getElementById("x" + item);
   if (visible) {
     obj.style.display="none";
     key.innerHTML="<img src='images/folder.gif' width='16' height='16'
hspace='0' vspace='0' border='0'>";
   } else {
      obj.style.display="block";
      key.innerHTML="<img src='images/textfolder.gif' width='16'
height='16' hspace='0' vspace='0' border='0'>";
   }
}


all works ok except the image wont be loaded.  I've tried all sorts of
different folder/path settings, even specifying the full pathname to the
image file and still it wont load.

it looks like when Ruby is rendering a .rhtml file, it can call a
javascript however the javascript cannot c reference any other files -
unless I'm missing something (which obviously I am and which is the
answer to the question!)

i've found the same thing happening if you call javascript "script1.js",
if it wants to call "script2.js" it seems to get lost and can't find it.


John
7cda78d70ab775710f6fa24e0a5b68db?d=identicon&s=25 Emin Hasanov (Guest)
on 2006-04-18 21:37
(Received via mailing list)
images shouls be referenced like src="/images"

did you try that?
This topic is locked and can not be replied to.