[Rails-spinoffs] reloading fragments of pages
Hello, I have a treeview, that works with scriptaculous in order to load the nodes dynamically. I also have in the main part of the page, a table with the list of elements. The lists of elements can be drag-dropped on the treeview in order to move them around (they are also draggable on other parts of the page) I need though, to refresh the treeview to reflect changes when a folder was moved (the branches changes) so i call the server to get a fragment of HTML (I know it could have been a fragment of XML, processed on client side but in my use case, it's a rendered HTML piece) This sent piece contains _javascript_ as well, in order to make the dynamic node still working. When the dom is reloaded, the drag/drop features reloads Droppable.drops elements. The new treeview html fragment IS the treeview that would be displayed on the page if the user would hit F5 after the drag. Everything work fine, except that the droppable areas of the freshly updated treeview are not enabled anymore. They do work on other droppable parts. here's the code that reload the treeview: var CPSPortletRefresher = Class.create(); CPSPortletRefresher.prototype = { initialize: function() { }, refreshPortletCompleted: function(originalRequest) { // getting new positions from the server result = originalRequest.responseText; if (result!='') { $(this.last_portlet_id).innerHTML = result; var newdiv = document.createElement("div"); newdiv.innerHTML = result; newdiv.id = this.last_portlet_id; olddiv = $(this.last_portlet_id); parent = olddiv.parentNode; olddiv.parentNode.replaceChild(newdiv, olddiv); } }, refreshPortlet: function(portlet_id) { var params = 'portlet_id=' + portlet_id; url = "" style="color: rgb(221, 0, 0);">'viewPortlet'; var refreshPortletCompletedBn = this.refreshPortletCompleted.bind(this); var options = {parameters: params, onComplete: refreshPortletCompletedBn}; this.last_portlet_id = portlet_id; var sender = new Ajax.Request(url, options); }, } var portlet_refresher = new CPSPortletRefresher(); So two question: 1/ is the innerHTML reliable for this kind of job ? 2/ Do I miss something ? :) Thanks ! Tarek -- Tarek Ziadé | Association AfPy | www.afpy.orgSite personnel | http://programmation-python.org ___ Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Re: [Rails-spinoffs] reloading fragments of pages
On 2/23/06, Tarek Ziadé <[EMAIL PROTECTED]> wrote: > When the dom is reloaded, the drag/drop features reloads Droppable.drops > elements. I think this statement is the heart of your problem. There's nothing active about scriptaculous (where you're getting the Draggables/Droppables from) that would check for a DOM "reload" (I'm not sure what that is? any change, perhaps?); I'm not even sure that kind of information is available to JavaScript. I don't know much about scriptaculous, so don't take this as the final answer, but the magic that makes Draggables/Droppables work are the events that are attached to each element that you make Draggable/Droppable. When you use .innerHTML on those elements' parent, you're effectively destroying the existing elements (and their event associations) and creating what might look like identical elements, but they're not; they don't have the events unless you programatically re-initialize the Draggables/Droppables. > refreshPortletCompleted: function(originalRequest) { > // getting new positions from the server > result = originalRequest.responseText; > > if (result!='') { > $(this.last_portlet_id).innerHTML = result; > var newdiv = document.createElement("div"); > newdiv.innerHTML = result; > newdiv.id = this.last_portlet_id; > olddiv = $(this.last_portlet_id); > parent = olddiv.parentNode; > olddiv.parentNode.replaceChild(newdiv, olddiv); > } > }, Isn't most of this code redundant? You only need to use innerHTML on the existing div, or create a new div and replace the old one. Either one achieves the same DOM structure in the end. You also never use 'parent' anywhere. Todd ___ Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Re: [Rails-spinoffs] reloading fragments of pages
You may try to use Ajax.Updater with the evalScripts option enabled.In the HTML code sent by the server, you'll have to include
RE: [Rails-spinoffs] reloading fragments of pages
Todd is exactly right. What's also important to realize about this, is that when your DOM elements are destroyed by the update to innerHTML, any event handlers that were tied to them (onclick, etc..), are in danger of staying around in memory (especially if the handlers are closures which hold references to the DOM elements, called a circular reference). These memory leaks can be very detrimental to your application if they go unchecked. Think of the control you're updating (the treeview) as a miniature page. Every time it's refreshed (via innerHTML), you need to re-setup all of it's client behaviors (which is what you're seeing now). But you also should take care to clean up all of it's resources before each update. You can do this by adding a dispose() method on your objects that detaches DOM event handlers, unregisters draggables and droppable... etc (basically any memory that the DOM elements which will be refreshed have a hold of needs to be released), and making sure dispose() gets called before the refresh happens. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Todd Ross Sent: Thursday, February 23, 2006 5:49 AM To: rails-spinoffs@lists.rubyonrails.org Subject: Re: [Rails-spinoffs] reloading fragments of pages On 2/23/06, Tarek Ziadé <[EMAIL PROTECTED]> wrote: > When the dom is reloaded, the drag/drop features reloads Droppable.drops > elements. I think this statement is the heart of your problem. There's nothing active about scriptaculous (where you're getting the Draggables/Droppables from) that would check for a DOM "reload" (I'm not sure what that is? any change, perhaps?); I'm not even sure that kind of information is available to JavaScript. I don't know much about scriptaculous, so don't take this as the final answer, but the magic that makes Draggables/Droppables work are the events that are attached to each element that you make Draggable/Droppable. When you use .innerHTML on those elements' parent, you're effectively destroying the existing elements (and their event associations) and creating what might look like identical elements, but they're not; they don't have the events unless you programatically re-initialize the Draggables/Droppables. > refreshPortletCompleted: function(originalRequest) { > // getting new positions from the server > result = originalRequest.responseText; > > if (result!='') { > $(this.last_portlet_id).innerHTML = result; > var newdiv = document.createElement("div"); > newdiv.innerHTML = result; > newdiv.id = this.last_portlet_id; > olddiv = $(this.last_portlet_id); > parent = olddiv.parentNode; > olddiv.parentNode.replaceChild(newdiv, olddiv); > } > }, Isn't most of this code redundant? You only need to use innerHTML on the existing div, or create a new div and replace the old one. Either one achieves the same DOM structure in the end. You also never use 'parent' anywhere. Todd ___ Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs The information transmitted in this electronic mail is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers. ___ Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
RE: [Rails-spinoffs] reloading fragments of pages
Ryan, Not related to this post, but you bring up a good point here. The dispose() method that you are talking about, is this something available in prototype or do we need to write it? Is it similar to unloadCache()? Doesn't prototype do the cleanups on every subsequent load? Please let me know. Thank you, Mandy. ___ Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Re: [Rails-spinoffs] reloading fragments of pages
On 2/23/06, Todd Ross <[EMAIL PROTECTED]> wrote: On 2/23/06, Tarek Ziadé <[EMAIL PROTECTED]> wrote:> When the dom is reloaded, the drag/drop features reloads Droppable.drops> elements.I think this statement is the heart of your problem. There's nothing active about scriptaculous (where you're getting theDraggables/Droppables from) that would check for a DOM "reload" (I'mnot sure what that is? any change, perhaps?); I'm not even sure thatkind of information is available to _javascript_. I don't know much about scriptaculous, so don't take this as the finalanswer, but the magic that makes Draggables/Droppables work are theevents that are attached to each element that you makeDraggable/Droppable. When you use .innerHTML on those elements' parent, you're effectively destroying the existing elements (and theirevent associations) and creating what might look like identicalelements, but they're not; they don't have the events unless youprogramatically re-initialize the Draggables/Droppables. yes that's what i am doind indeed, i should've been clearer: after the fragment is reloaded, i relaunch the initialisation of drag/drop stuff > refreshPortletCompleted: function(originalRequest) {> // getting new positions from the server > result = originalRequest.responseText;>> if (result!='') {> $(this.last_portlet_id).innerHTML = result;> var newdiv = document.createElement("div");> newdiv.innerHTML = result;> newdiv.id = this.last_portlet_id;> olddiv = $(this.last_portlet_id);> parent = olddiv.parentNode;> olddiv.parentNode.replaceChild(newdiv, olddiv); > }> },Isn't most of this code redundant? You only need to use innerHTML onthe existing div, or create a new div and replace the old one. Eitherone achieves the same DOM structure in the end. this is part of my problem: if i do a direct innerHTML of the code, the _javascript_ that's inside of this fragment is not "effective" creating a new node solves this issue. You also never use'parent' anywhere. oups right thx Todd___Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.orghttp://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs -- Tarek Ziadé | Association AfPy | www.afpy.orgSite personnel | http://programmation-python.org ___ Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
RE: [Rails-spinoffs] reloading fragments of pages
No it's something you would have to write. Protoype's unloadCache() happens on page unload... we're talking here about a single control being updated (not the whole page). So in a long-running AJAX application, the page itself may never get refreshed, there prototype would never call unloadCache(). This cleanup stuff really needs to be at an atomic per control level to support designing a scalable AJAX application. I've even gone as far as to create a garbage collector to handle this cleanup on a background process. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Maninder, Singh Sent: Thursday, February 23, 2006 9:25 AM To: rails-spinoffs@lists.rubyonrails.org Subject: RE: [Rails-spinoffs] reloading fragments of pages Ryan, Not related to this post, but you bring up a good point here. The dispose() method that you are talking about, is this something available in prototype or do we need to write it? Is it similar to unloadCache()? Doesn't prototype do the cleanups on every subsequent load? Please let me know. Thank you, Mandy. ___ Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs The information transmitted in this electronic mail is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers. ___ Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Re: [Rails-spinoffs] reloading fragments of pages
On 2/23/06, Nicolas <[EMAIL PROTECTED]> wrote: You may try to use Ajax.Updater with the evalScripts option enabled. thanks i am going to try that In the HTML code sent by the server, you'll have to include
RE: [Rails-spinoffs] reloading fragments of pages
Thanks once again Ryan. Are you planning to share your code? :) ___ Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Re: [Rails-spinoffs] reloading fragments of pages
On 2/23/06, Ryan Gahl <[EMAIL PROTECTED]> wrote: Todd is exactly right. What's also important to realize about this, is that when your DOM elements are destroyed by the update to innerHTML, any event handlers that were tied to them (onclick, etc..), are in danger of staying around in memory (especially if the handlers are closures which hold references to the DOM elements, called a circular reference). These memory leaks can be very detrimental to your application if they go unchecked.Think of the control you're updating (the treeview) as a miniature page. Every time it's refreshed (via innerHTML), you need to re-setup all of it's client behaviors (which is what you're seeing now). But you also should take care to clean up all of it's resources before each update. You can do this by adding a dispose() method on your objects that detaches DOM event handlers, unregisters draggables and droppable... etc (basically any memory that the DOM elements which will be refreshed have a hold of needs to be released), and making sure dispose() gets called before the refresh happens. yes, i had this problem earlier; i have set a hookEvents/unHookEvents that is is charge of cleaning up things when the fragment is reloaded, but the dispose() thing is better thx, i'll do that Tarek ___ Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
RE: [Rails-spinoffs] reloading fragments of pages
Perhaps. Very busy right now. :-) Time will tell. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Maninder, Singh Sent: Thursday, February 23, 2006 9:32 AM To: rails-spinoffs@lists.rubyonrails.org Subject: RE: [Rails-spinoffs] reloading fragments of pages Thanks once again Ryan. Are you planning to share your code? :) ___ Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs The information transmitted in this electronic mail is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers. ___ Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
[Rails-spinoffs] question about getElementsByClassName
i would like to detect classnames of input_(ANYTHING) is this possible with getElementsByClassName? also, is tthere a way to get elements by attribute? or would that be too heavy on the load time? ___ Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Re: [Rails-spinoffs] question about getElementsByClassName
Louis Walch wrote: > i would like to detect classnames of input_(ANYTHING) is this possible > with getElementsByClassName? Looking at the source code you could do getELementsByClassName("input_.+");, although it's undocumented behaviour so it might mysteriously break after a prototype upgrade one day. I know the current method (of using a regexp) is one of the slowest ways of doing it. > > also, is tthere a way to get elements by attribute? or would that be too > heavy on the load time? That shouldn't be too intensive. See prototype.js's defnition for getElementsByClassName and hack your own. What attribute would this be useful for? Getting all text inputs? I would just getElementsByTagName and do a quick loop. -Rob > ___ > Rails-spinoffs mailing list > Rails-spinoffs@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs ___ Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Re: [Rails-spinoffs] question about getElementsByClassName
thanks rob, i will give input_.+ a shot. i use a custom attrib named fldtype for some input items and am hoping to assign different actions to each input based on that. > > > Louis Walch wrote: >> i would like to detect classnames of input_(ANYTHING) is this possible >> with getElementsByClassName? > > Looking at the source code you could do > getELementsByClassName("input_.+");, although it's undocumented > behaviour so it might mysteriously break after a prototype upgrade one > day. I know the current method (of using a regexp) is one of the slowest > ways of doing it. > >> >> also, is tthere a way to get elements by attribute? or would that be too >> heavy on the load time? > > That shouldn't be too intensive. See prototype.js's defnition for > getElementsByClassName and hack your own. What attribute would this be > useful for? Getting all text inputs? I would just getElementsByTagName > and do a quick loop. > > -Rob > >> ___ >> Rails-spinoffs mailing list >> Rails-spinoffs@lists.rubyonrails.org >> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > ___ > Rails-spinoffs mailing list > Rails-spinoffs@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > ___ Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Re: [Rails-spinoffs] question about getElementsByClassName
Louis, In this senario, I usually add a class to the set of elements I'm interested in getting back to later on by doing a Element.addClassName() and then doing a getElementsByClassName() later on. You can remove the 'dummy' class later if you need to: Element.removeClassName() Hope this helps. Regards, Cam On 2/23/06, Louis Walch <[EMAIL PROTECTED]> wrote: > thanks rob, i will give input_.+ a shot. > > i use a custom attrib named fldtype for some input items and am hoping to > assign different actions to each input based on that. > > > > > > > > > > Louis Walch wrote: > >> i would like to detect classnames of input_(ANYTHING) is this possible > >> with getElementsByClassName? > > > > Looking at the source code you could do > > getELementsByClassName("input_.+");, although it's undocumented > > behaviour so it might mysteriously break after a prototype upgrade one > > day. I know the current method (of using a regexp) is one of the slowest > > ways of doing it. > > > >> > >> also, is tthere a way to get elements by attribute? or would that be too > >> heavy on the load time? > > > > That shouldn't be too intensive. See prototype.js's defnition for > > getElementsByClassName and hack your own. What attribute would this be > > useful for? Getting all text inputs? I would just getElementsByTagName > > and do a quick loop. > > > > -Rob > > > >> ___ > >> Rails-spinoffs mailing list > >> Rails-spinoffs@lists.rubyonrails.org > >> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > ___ > > Rails-spinoffs mailing list > > Rails-spinoffs@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > ___ > Rails-spinoffs mailing list > Rails-spinoffs@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > -- Cam McVey [EMAIL PROTECTED] ___ Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Re: [Rails-spinoffs] question about getElementsByClassName
i made a function which was a near duplicate of getElementsByClassName and saved it as getInputsByAttribute and saved it in an external js file. but now i am getting "getInputsByAttribute can not be found" is there something i need to do to make it part of prototype? > > > Louis Walch wrote: >> i would like to detect classnames of input_(ANYTHING) is this possible >> with getElementsByClassName? > > Looking at the source code you could do > getELementsByClassName("input_.+");, although it's undocumented > behaviour so it might mysteriously break after a prototype upgrade one > day. I know the current method (of using a regexp) is one of the slowest > ways of doing it. > >> >> also, is tthere a way to get elements by attribute? or would that be too >> heavy on the load time? > > That shouldn't be too intensive. See prototype.js's defnition for > getElementsByClassName and hack your own. What attribute would this be > useful for? Getting all text inputs? I would just getElementsByTagName > and do a quick loop. > > -Rob > >> ___ >> Rails-spinoffs mailing list >> Rails-spinoffs@lists.rubyonrails.org >> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > ___ > Rails-spinoffs mailing list > Rails-spinoffs@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > ___ Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Re: [Rails-spinoffs] question about getElementsByClassName
On 2/23/06, Louis Walch <[EMAIL PROTECTED]> wrote: > i made a function which was a near duplicate of getElementsByClassName and > saved it as getInputsByAttribute and saved it in an external js file. > > but now i am getting "getInputsByAttribute can not be found" is there > something i need to do to make it part of prototype? 1) Are you including your /separate/ JavaScript file into the page that you're trying to use it from? 2) What element (or object) are you attempting to call getInputsByAttribute on? 3) How did you declare the function (or method)? Show us the code. A live site is generally preferrable. Todd ___ Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Re: [Rails-spinoffs] question about getElementsByClassName
the file is being included, it is in the top of my common.js i am getting the error before it does anything. could it be that my common.js is not written in the OO style of js? here is the code; document.getInputsByAttribute = function(attrib,val){ //Add-on to Prototype var children = document.getElementsByTagName('INPUT'); var elements = new Array(); for (var i = 0; i < children.length; i++) { if (children[i].getAttribute(attrib) == val){ elements.push(children[i]); } } return elements; } > On 2/23/06, Louis Walch <[EMAIL PROTECTED]> wrote: >> i made a function which was a near duplicate of getElementsByClassName >> and >> saved it as getInputsByAttribute and saved it in an external js file. >> >> but now i am getting "getInputsByAttribute can not be found" is there >> something i need to do to make it part of prototype? > > 1) Are you including your /separate/ JavaScript file into the page > that you're trying to use it from? > > 2) What element (or object) are you attempting to call > getInputsByAttribute on? > > 3) How did you declare the function (or method)? > > Show us the code. A live site is generally preferrable. > > Todd > ___ > Rails-spinoffs mailing list > Rails-spinoffs@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > ___ Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Re: [Rails-spinoffs] question about getElementsByClassName
On 2/23/06, Louis Walch <[EMAIL PROTECTED]> wrote: > the file is being included, it is in the top of my common.js > > i am getting the error before it does anything. could it be that my > common.js is not written in the OO style of js? > > here is the code; And ... how are you calling it? Todd ___ Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Re: [Rails-spinoffs] question about getElementsByClassName
whoops, sorry function displayPreviewIcon(){ inputs = getInputsByAttribute('fldtype','filelocation'); for(i=0; i < inputs.length; i++){ //Testing inputs[i].style.backgroundColor = '#ff00ff'; } } which is called onLoad > On 2/23/06, Louis Walch <[EMAIL PROTECTED]> wrote: >> the file is being included, it is in the top of my common.js >> >> i am getting the error before it does anything. could it be that my >> common.js is not written in the OO style of js? >> >> here is the code; > > And ... how are you calling it? > > Todd > ___ > Rails-spinoffs mailing list > Rails-spinoffs@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > ___ Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Re: [Rails-spinoffs] question about getElementsByClassName
On 2/23/06, Louis Walch <[EMAIL PROTECTED]> wrote: > whoops, sorry > > > function displayPreviewIcon(){ > inputs = getInputsByAttribute('fldtype','filelocation'); > for(i=0; i < inputs.length; i++){ > //Testing > inputs[i].style.backgroundColor = '#ff00ff'; > } > } > > > which is called onLoad When you call a function, that function is executed (by default) in the global context. In client-side development, the global context is the 'window' object, not the 'document' object. Either redefine your function as window.getInputsByAttribute (or, don't use an object qualifier at all; it'll default to 'window') or call it as document.getInputsByAttribute, which is where you're defining it. When you access 'document', it's really giving you 'window.document', so your function is really 'window.document.getInputsByAttribute'. There's an extra layer you're not accounting for. Todd ___ Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Re: [Rails-spinoffs] question about getElementsByClassName
duh, ok. sorry and thanks for the help! > On 2/23/06, Louis Walch <[EMAIL PROTECTED]> wrote: >> whoops, sorry >> >> >> function displayPreviewIcon(){ >> inputs = getInputsByAttribute('fldtype','filelocation'); >> for(i=0; i < inputs.length; i++){ >> //Testing >> inputs[i].style.backgroundColor = '#ff00ff'; >> } >> } >> >> >> which is called onLoad > > When you call a function, that function is executed (by default) in > the global context. In client-side development, the global context is > the 'window' object, not the 'document' object. Either redefine your > function as window.getInputsByAttribute (or, don't use an object > qualifier at all; it'll default to 'window') or call it as > document.getInputsByAttribute, which is where you're defining it. > > When you access 'document', it's really giving you 'window.document', > so your function is really 'window.document.getInputsByAttribute'. > There's an extra layer you're not accounting for. > > Todd > ___ > Rails-spinoffs mailing list > Rails-spinoffs@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > ___ Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
[Rails-spinoffs] suggestion $c()
i think it would be a good idea to map a shortcut to getElementsByClassName like the much loved $(). i think $c() seems applicable. ___ Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Re: [Rails-spinoffs] suggestion $c()
You can use the new $$ with '.' example $$('.className') returns an array of all elements with the class name 'className'On 2/23/06, Louis Walch < [EMAIL PROTECTED]> wrote:i think it would be a good idea to map a shortcut to getElementsByClassName like the much loved $(). i think $c() seemsapplicable.___Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.orghttp://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs -- Yehuda KatzWeb Developer(ph) 718.877.1325(fax) 718.686.4288 ___ Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
RE: [Rails-spinoffs] suggestion $c()
Awesome, I guess I missed that one. Thanks. From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Yehuda Katz Sent: Thursday, February 23, 2006 8:36 PM To: rails-spinoffs@lists.rubyonrails.org Subject: Re: [Rails-spinoffs] suggestion $c() You can use the new $$ with '.' example $$('.className') returns an array of all elements with the class name 'className' On 2/23/06, Louis Walch < [EMAIL PROTECTED]> wrote: i think it would be a good idea to map a shortcut to getElementsByClassName like the much loved $(). i think $c() seems applicable. ___ Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs -- Yehuda Katz Web Developer (ph) 718.877.1325 (fax) 718.686.4288 ___ Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Re: [Rails-spinoffs] Insertion.Top
My apologies the correct url is http://www.talaha.com/macnn/ test_insert.html Thank you. On Feb 21, 2006, at 4:22 PM, Whitcraft, Jon wrote: The url does not work. Jon Whitcraft Web Application Developer Online Services - Indianapolis Motor Speedway (317) 492-8623 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Farhan Sent: Tuesday, February 21, 2006 4:15 PM To: rails-spinoffs@lists.rubyonrails.org Subject: [Rails-spinoffs] Insertion.Top hi all, Can someone please help me with the Insertion.Top not working IE 6 browsers? I have an example at http://www.talaha.com/macnn/test_insertion.html It works in both Firefox (1.5 Mac/Win) and Safari; but does not work in IE 6. Thanks in advance. Cheers. ___ Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs This E-mail (and attachments) may contain confidential/privileged information intended only for the named addressee(s). If you are not an intended recipient, do not read, copy, disseminate or take any action based on the content of this E-mail. Please notify the sender by reply E-mail and erase this E-mail from your system. Your assistance is appreciated. E-mail transmission may not be secure or error-free. The company is not responsible for any loss/damage arising from any virus transmitted. ___ Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs ___ Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Re: [Rails-spinoffs] suggestion $c()
It only works in the svn version of Prototype. The current stable version does not have it.On 2/23/06, louis d walch < [EMAIL PROTECTED]> wrote: Awesome, I guess I missed that one. Thanks. From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Yehuda Katz Sent: Thursday, February 23, 2006 8:36 PM To: rails-spinoffs@lists.rubyonrails.org Subject: Re: [Rails-spinoffs] suggestion $c() You can use the new $$ with '.' example $$('.className') returns an array of all elements with the class name 'className' On 2/23/06, Louis Walch < [EMAIL PROTECTED]> wrote: i think it would be a good idea to map a shortcut to getElementsByClassName like the much loved $(). i think $c() seems applicable. ___ Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs -- Yehuda Katz Web Developer (ph) 718.877.1325 (fax) 718.686.4288 ___Rails-spinoffs mailing listRails-spinoffs@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs -- Yehuda KatzWeb Developer(ph) 718.877.1325(fax) 718.686.4288 ___ Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
[Rails-spinoffs] Adding a new Sortable
Perhaps this is elementary, but I'm having trouble finding something in the documentation. I'm attempting to create a page with a form for new data submission and below it a list (a Sortable) of the various records. I'm unsure how to make the form so that it will automatically create a new element to the Sortable with the data that gets Ajaxed back from the server. Is there a Sortable.add method or something like that?visual description (yay, pictures!): <-- how do I get a new record to show up here? row1row2make sortableThanks everybody, - Danger ___ Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs