I was looking at the CHANGELOGS for actionpack and it said that Toggle.display was depreciated for Element.toggle I have a form element with and id of ''project_3'', when I call Element.toggle(''project_3'') it doesn''t change. It still works with Toggle.display(''project_3'') though. I updated my rails to the new version and did rails . on the project dir. I looked at the source for prototype.js and the element toggle is there: var Element = { toggle: function() { for (var i = 0; i < arguments.length; i++) { var element = $(arguments[i]); element.style.display (element.style.display == ''none'' ? '''' : ''none''); } }, hide: function() { for (var i = 0; i < arguments.length; i++) { var element = $(arguments[i]); element.style.display = ''none''; } }, How do I use this? Thanks, dom
On 19 Apr 05, at 3:51 PM, Dominic Sisneros wrote:> I was looking at the CHANGELOGS for actionpack and it said that > Toggle.display was depreciated for Element.toggle I have a form > element with and id of ''project_3'', when I call > Element.toggle(''project_3'') it doesn''t change. It still works with > Toggle.display(''project_3'') though. I updated my rails to the new > version and did rails . on the project dir. I looked at the source > for prototype.js and the element toggle is there:Strange, it works for me. I just replaced Toggle.display with Element.toggle and it worked. Sure you didn''t change something else at the same time? Judging by the code I don''t think there should be any difference. (Not that I know javascript but I think I know what this means: Toggle.display = Element.toggle; ) -- -asbjxrn
This could just be a caching issue, depending on your browser. Various versions of IE (and some Mozilla-based browsers) do odd things when caching JavaScript. Try holding down Shift and hitting the reload button on your browser, which *should* force the browser to refresh its cache. Or just completely shutdown your browser and start it again, or just clear the cache in the browser''s preferences. Just an idea. I''ve seen a lot of oddities where I add something to a JavaScript file and then get weird errors in my browser. If you''re using Firefox, you could open up the JavaScript Console to see if there is an uncaught exception. Often times, this can make it easier to debug these sorts of situations, especially if it''s something simple like a spelling mistake. Cheers, Ben On 4/19/05, Dominic Sisneros <dsisnero-Wuw85uim5zDR7s880joybQ@public.gmane.org> wrote:> I was looking at the CHANGELOGS for actionpack and it said that > Toggle.display was depreciated for Element.toggle I have a form element > with and id of ''project_3'', when I call Element.toggle(''project_3'') it > doesn''t change. It still works with Toggle.display(''project_3'') > though. I updated my rails to the new version and did rails . on the > project dir. I looked at the source for prototype.js and the element > toggle is there: > > var Element = { > toggle: function() { > for (var i = 0; i < arguments.length; i++) { > var element = $(arguments[i]); > element.style.display > (element.style.display == ''none'' ? '''' : ''none''); > } > }, > > hide: function() { > for (var i = 0; i < arguments.length; i++) { > var element = $(arguments[i]); > element.style.display = ''none''; > } > }, > > How do I use this? > > Thanks, > > dom > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Ben Schumacher wrote: | This could just be a caching issue, depending on your browser. Various For that matter, did you copy the new prototype.js from the new distro? You have to find it in the vendor or system files, and copy it to public/javascripts by hand (unless you have symlinked it) - -- David Morton Maia Mailguard server side anti-spam/anti-virus solution: http://www.maiamailguard.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFCZX4hSIxC85HZHLMRAufjAJ9nVDZUOyBJBLOa3pFVCmI0fMuMTgCgnEjX 251lYT4J/+xdbwKekG5+Cn4=Nx/F -----END PGP SIGNATURE-----
Thanks everyone for your responses I finally got this working. The problem was that I was loading prototype-ex.js from http://darthapo.com/repos/taskthis/public/javascripts/prototype-ex.js and the excellent taskthis demonstration. This code was the basis for some of the patches to the new prototype library and already had an Element var and functions. I deleted the similar functions and extended the Element "class" instead of re-declaring it. In prototype-ex.js, I now have ( I might get rid of these if I don''t use them) Element.extend( { has_class: function(dom, classname) { return $(dom).className.split('' '').contains(classname); }, add_class: function(dom, classname) { var elem = $(dom); if (elem.className.split('' '').contains(classname)) return; elem.className += ( elem.className.length ? '' '' : '''' ) + classname; }, remove_class: function(dom, classname) { var elem = $(dom); elem.className = elem.className.split('' '').remove(classname).join('' ''); }, toggle_class: function(dom, classname) { if ( this.has_class( dom, classname ) ) this.remove_class( dom, classname ); else this.add_class( dom, classname ); return !!this.has_class( dom, classname ); }, get: function(obj) { return $(obj); }, get_with_class: function(className, parent_element) { var children = (parent_element || document).getElementsByTagName(''*''); var elements = new Array(); for (var i = 0; i < children.length; i++) { if( this.has_class( children[i], className ) ) elements.push(child); } return elements; }, get_list: function (el) { if( Var.is_element(el) ) return [el]; else if( Var.is_string(el) ) return this.get_list(el.split(/\s+/g)); else if( Var.is_list(el) ) { var r = map(el, this.get); return filter(r, Var.is_element).length==r.length? r : null; } else return null; } }); David Morton wrote:> -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Ben Schumacher wrote:> | This could just be a caching issue, depending on your browser. Various > > For that matter, did you copy the new prototype.js from the new distro? > You have to find it in the vendor or system files, and copy it to > public/javascripts by hand (unless you have symlinked it) > > > - -- > David Morton > Maia Mailguard server side anti-spam/anti-virus solution: > http://www.maiamailguard.com > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.2.5 (GNU/Linux) > Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org > > iD8DBQFCZX4hSIxC85HZHLMRAufjAJ9nVDZUOyBJBLOa3pFVCmI0fMuMTgCgnEjX > 251lYT4J/+xdbwKekG5+Cn4> =Nx/F > -----END PGP SIGNATURE----- > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >