[Proto-Scripty] Prototype, addClassName on future elements
I'm trying to append a class via addClassName on future elements on a page with Prototype, however I do seem to struggle a bit with it. I know of jQuery's .live feature, but I cannot find a similar feature in Prototype. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To view this discussion on the web visit https://groups.google.com/d/msg/prototype-scriptaculous/-/3R9rCrWTjaIJ. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
Re: [Proto-Scripty] Prototype, addClassName on future elements
Can you describe what you mean by future elements on the page? Do you mean elements that are later in the source order than the script? If so, that's pretty simple: document.observe('dom:loaded', function(){ $$('div.foo').invoke('addClassName', 'bar'); }); Walter On Oct 24, 2012, at 7:52 AM, Henrik Aagaard Sørensen wrote: I'm trying to append a class via addClassName on future elements on a page with Prototype, however I do seem to struggle a bit with it. I know of jQuery's .live feature, but I cannot find a similar feature in Prototype. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To view this discussion on the web visit https://groups.google.com/d/msg/prototype-scriptaculous/-/3R9rCrWTjaIJ. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
Re: [Proto-Scripty] Prototype, addClassName on future elements
No, unfortunately it's not that. It's elements being loaded into the dom later. I'm already using dom:loaded and I've placed the JS jus before /body as the last element. However, there are several Ajax-calls which later (in the future, after everything is loaded) creates new elements (which I have no control over), so I need to have Prototype adding specific class-names in elements which fullfill CSS selector at all time. On Wed, Oct 24, 2012 at 1:57 PM, Walter Lee Davis wa...@wdstudio.comwrote: Can you describe what you mean by future elements on the page? Do you mean elements that are later in the source order than the script? If so, that's pretty simple: document.observe('dom:loaded', function(){ $$('div.foo').invoke('addClassName', 'bar'); }); Walter On Oct 24, 2012, at 7:52 AM, Henrik Aagaard Sørensen wrote: I'm trying to append a class via addClassName on future elements on a page with Prototype, however I do seem to struggle a bit with it. I know of jQuery's .live feature, but I cannot find a similar feature in Prototype. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To view this discussion on the web visit https://groups.google.com/d/msg/prototype-scriptaculous/-/3R9rCrWTjaIJ. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
Re: [Proto-Scripty] Prototype, addClassName on future elements
You can add this transformation in the onSuccess callback of your Ajax call: new Ajax.Updater('foo', '/get/more/foo', {onSuccess: function(){ $$('.foo').invoke('addClassName', 'bar'); }); As long as you don't have a ton of DOM changes happening, this should just work. Otherwise, you may want to wrap it in a Defer to ensure that the DOM is stable before you run it. Walter On Oct 24, 2012, at 8:00 AM, Henrik Aagaard Sørensen wrote: No, unfortunately it's not that. It's elements being loaded into the dom later. I'm already using dom:loaded and I've placed the JS jus before /body as the last element. However, there are several Ajax-calls which later (in the future, after everything is loaded) creates new elements (which I have no control over), so I need to have Prototype adding specific class-names in elements which fullfill CSS selector at all time. On Wed, Oct 24, 2012 at 1:57 PM, Walter Lee Davis wa...@wdstudio.com wrote: Can you describe what you mean by future elements on the page? Do you mean elements that are later in the source order than the script? If so, that's pretty simple: document.observe('dom:loaded', function(){ $$('div.foo').invoke('addClassName', 'bar'); }); Walter On Oct 24, 2012, at 7:52 AM, Henrik Aagaard Sørensen wrote: I'm trying to append a class via addClassName on future elements on a page with Prototype, however I do seem to struggle a bit with it. I know of jQuery's .live feature, but I cannot find a similar feature in Prototype. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To view this discussion on the web visit https://groups.google.com/d/msg/prototype-scriptaculous/-/3R9rCrWTjaIJ. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
Re: [Proto-Scripty] Prototype, addClassName on future elements
Hi Walter. Thank you for your answer, however, I do not have the ability to change the Ajax-calls. It's external scripts which is being loaded. On Wed, Oct 24, 2012 at 2:32 PM, Walter Lee Davis wa...@wdstudio.comwrote: You can add this transformation in the onSuccess callback of your Ajax call: new Ajax.Updater('foo', '/get/more/foo', {onSuccess: function(){ $$('.foo').invoke('addClassName', 'bar'); }); As long as you don't have a ton of DOM changes happening, this should just work. Otherwise, you may want to wrap it in a Defer to ensure that the DOM is stable before you run it. Walter On Oct 24, 2012, at 8:00 AM, Henrik Aagaard Sørensen wrote: No, unfortunately it's not that. It's elements being loaded into the dom later. I'm already using dom:loaded and I've placed the JS jus before /body as the last element. However, there are several Ajax-calls which later (in the future, after everything is loaded) creates new elements (which I have no control over), so I need to have Prototype adding specific class-names in elements which fullfill CSS selector at all time. On Wed, Oct 24, 2012 at 1:57 PM, Walter Lee Davis wa...@wdstudio.com wrote: Can you describe what you mean by future elements on the page? Do you mean elements that are later in the source order than the script? If so, that's pretty simple: document.observe('dom:loaded', function(){ $$('div.foo').invoke('addClassName', 'bar'); }); Walter On Oct 24, 2012, at 7:52 AM, Henrik Aagaard Sørensen wrote: I'm trying to append a class via addClassName on future elements on a page with Prototype, however I do seem to struggle a bit with it. I know of jQuery's .live feature, but I cannot find a similar feature in Prototype. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To view this discussion on the web visit https://groups.google.com/d/msg/prototype-scriptaculous/-/3R9rCrWTjaIJ. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
Re: [Proto-Scripty] Prototype, addClassName on future elements
And I've tried the defer as well, didn't do the job as the call stack will be ready between Ajax calls. On Wed, Oct 24, 2012 at 2:34 PM, Henrik Aagaard Sørensen henrikaagaardsoren...@gmail.com wrote: Hi Walter. Thank you for your answer, however, I do not have the ability to change the Ajax-calls. It's external scripts which is being loaded. On Wed, Oct 24, 2012 at 2:32 PM, Walter Lee Davis wa...@wdstudio.comwrote: You can add this transformation in the onSuccess callback of your Ajax call: new Ajax.Updater('foo', '/get/more/foo', {onSuccess: function(){ $$('.foo').invoke('addClassName', 'bar'); }); As long as you don't have a ton of DOM changes happening, this should just work. Otherwise, you may want to wrap it in a Defer to ensure that the DOM is stable before you run it. Walter On Oct 24, 2012, at 8:00 AM, Henrik Aagaard Sørensen wrote: No, unfortunately it's not that. It's elements being loaded into the dom later. I'm already using dom:loaded and I've placed the JS jus before /body as the last element. However, there are several Ajax-calls which later (in the future, after everything is loaded) creates new elements (which I have no control over), so I need to have Prototype adding specific class-names in elements which fullfill CSS selector at all time. On Wed, Oct 24, 2012 at 1:57 PM, Walter Lee Davis wa...@wdstudio.com wrote: Can you describe what you mean by future elements on the page? Do you mean elements that are later in the source order than the script? If so, that's pretty simple: document.observe('dom:loaded', function(){ $$('div.foo').invoke('addClassName', 'bar'); }); Walter On Oct 24, 2012, at 7:52 AM, Henrik Aagaard Sørensen wrote: I'm trying to append a class via addClassName on future elements on a page with Prototype, however I do seem to struggle a bit with it. I know of jQuery's .live feature, but I cannot find a similar feature in Prototype. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To view this discussion on the web visit https://groups.google.com/d/msg/prototype-scriptaculous/-/3R9rCrWTjaIJ. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
Re: [Proto-Scripty] Prototype, addClassName on future elements
Okay, then try this (wasteful but should do the job): new PeriodicalExecuter(function(){ $$('.foo').invoke('addClassName', 'bar'); }, 0.3); There's also an event (not uniformly covered by the browsers) that is fired when a DOM element is changed. Try observing DomSubtreeModified and hooking off of that to fire your class modification. Walter On Oct 24, 2012, at 8:34 AM, Henrik Aagaard Sørensen wrote: Hi Walter. Thank you for your answer, however, I do not have the ability to change the Ajax-calls. It's external scripts which is being loaded. On Wed, Oct 24, 2012 at 2:32 PM, Walter Lee Davis wa...@wdstudio.com wrote: You can add this transformation in the onSuccess callback of your Ajax call: new Ajax.Updater('foo', '/get/more/foo', {onSuccess: function(){ $$('.foo').invoke('addClassName', 'bar'); }); As long as you don't have a ton of DOM changes happening, this should just work. Otherwise, you may want to wrap it in a Defer to ensure that the DOM is stable before you run it. Walter On Oct 24, 2012, at 8:00 AM, Henrik Aagaard Sørensen wrote: No, unfortunately it's not that. It's elements being loaded into the dom later. I'm already using dom:loaded and I've placed the JS jus before /body as the last element. However, there are several Ajax-calls which later (in the future, after everything is loaded) creates new elements (which I have no control over), so I need to have Prototype adding specific class-names in elements which fullfill CSS selector at all time. On Wed, Oct 24, 2012 at 1:57 PM, Walter Lee Davis wa...@wdstudio.com wrote: Can you describe what you mean by future elements on the page? Do you mean elements that are later in the source order than the script? If so, that's pretty simple: document.observe('dom:loaded', function(){ $$('div.foo').invoke('addClassName', 'bar'); }); Walter On Oct 24, 2012, at 7:52 AM, Henrik Aagaard Sørensen wrote: I'm trying to append a class via addClassName on future elements on a page with Prototype, however I do seem to struggle a bit with it. I know of jQuery's .live feature, but I cannot find a similar feature in Prototype. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To view this discussion on the web visit https://groups.google.com/d/msg/prototype-scriptaculous/-/3R9rCrWTjaIJ. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
Re: [Proto-Scripty] Prototype, addClassName on future elements
PeriodicalExecuter does the job, thank you. However, I would like to try DomSubtreeModified. But this doesn't work in Chrome: document.observe('DomSubtreeModified ', function () { //Do stuff }); Am I doing something wrong? On Wed, Oct 24, 2012 at 2:47 PM, Walter Lee Davis wa...@wdstudio.comwrote: Okay, then try this (wasteful but should do the job): new PeriodicalExecuter(function(){ $$('.foo').invoke('addClassName', 'bar'); }, 0.3); There's also an event (not uniformly covered by the browsers) that is fired when a DOM element is changed. Try observing DomSubtreeModified and hooking off of that to fire your class modification. Walter On Oct 24, 2012, at 8:34 AM, Henrik Aagaard Sørensen wrote: Hi Walter. Thank you for your answer, however, I do not have the ability to change the Ajax-calls. It's external scripts which is being loaded. On Wed, Oct 24, 2012 at 2:32 PM, Walter Lee Davis wa...@wdstudio.com wrote: You can add this transformation in the onSuccess callback of your Ajax call: new Ajax.Updater('foo', '/get/more/foo', {onSuccess: function(){ $$('.foo').invoke('addClassName', 'bar'); }); As long as you don't have a ton of DOM changes happening, this should just work. Otherwise, you may want to wrap it in a Defer to ensure that the DOM is stable before you run it. Walter On Oct 24, 2012, at 8:00 AM, Henrik Aagaard Sørensen wrote: No, unfortunately it's not that. It's elements being loaded into the dom later. I'm already using dom:loaded and I've placed the JS jus before /body as the last element. However, there are several Ajax-calls which later (in the future, after everything is loaded) creates new elements (which I have no control over), so I need to have Prototype adding specific class-names in elements which fullfill CSS selector at all time. On Wed, Oct 24, 2012 at 1:57 PM, Walter Lee Davis wa...@wdstudio.com wrote: Can you describe what you mean by future elements on the page? Do you mean elements that are later in the source order than the script? If so, that's pretty simple: document.observe('dom:loaded', function(){ $$('div.foo').invoke('addClassName', 'bar'); }); Walter On Oct 24, 2012, at 7:52 AM, Henrik Aagaard Sørensen wrote: I'm trying to append a class via addClassName on future elements on a page with Prototype, however I do seem to struggle a bit with it. I know of jQuery's .live feature, but I cannot find a similar feature in Prototype. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To view this discussion on the web visit https://groups.google.com/d/msg/prototype-scriptaculous/-/3R9rCrWTjaIJ. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to
Re: [Proto-Scripty] Prototype, addClassName on future elements
DOM should be all caps. I just tried this in Safari 6, and while I couldn't get SubtreeModified to work, DOMNodeInserted worked great. You might want to try that. It works no matter what sort of content you insert -- even a bare string is a new DOM node. Walter On Oct 24, 2012, at 8:52 AM, Henrik Aagaard Sørensen wrote: PeriodicalExecuter does the job, thank you. However, I would like to try DomSubtreeModified. But this doesn't work in Chrome: document.observe('DomSubtreeModified ', function () { //Do stuff }); Am I doing something wrong? On Wed, Oct 24, 2012 at 2:47 PM, Walter Lee Davis wa...@wdstudio.com wrote: Okay, then try this (wasteful but should do the job): new PeriodicalExecuter(function(){ $$('.foo').invoke('addClassName', 'bar'); }, 0.3); There's also an event (not uniformly covered by the browsers) that is fired when a DOM element is changed. Try observing DomSubtreeModified and hooking off of that to fire your class modification. Walter On Oct 24, 2012, at 8:34 AM, Henrik Aagaard Sørensen wrote: Hi Walter. Thank you for your answer, however, I do not have the ability to change the Ajax-calls. It's external scripts which is being loaded. On Wed, Oct 24, 2012 at 2:32 PM, Walter Lee Davis wa...@wdstudio.com wrote: You can add this transformation in the onSuccess callback of your Ajax call: new Ajax.Updater('foo', '/get/more/foo', {onSuccess: function(){ $$('.foo').invoke('addClassName', 'bar'); }); As long as you don't have a ton of DOM changes happening, this should just work. Otherwise, you may want to wrap it in a Defer to ensure that the DOM is stable before you run it. Walter On Oct 24, 2012, at 8:00 AM, Henrik Aagaard Sørensen wrote: No, unfortunately it's not that. It's elements being loaded into the dom later. I'm already using dom:loaded and I've placed the JS jus before /body as the last element. However, there are several Ajax-calls which later (in the future, after everything is loaded) creates new elements (which I have no control over), so I need to have Prototype adding specific class-names in elements which fullfill CSS selector at all time. On Wed, Oct 24, 2012 at 1:57 PM, Walter Lee Davis wa...@wdstudio.com wrote: Can you describe what you mean by future elements on the page? Do you mean elements that are later in the source order than the script? If so, that's pretty simple: document.observe('dom:loaded', function(){ $$('div.foo').invoke('addClassName', 'bar'); }); Walter On Oct 24, 2012, at 7:52 AM, Henrik Aagaard Sørensen wrote: I'm trying to append a class via addClassName on future elements on a page with Prototype, however I do seem to struggle a bit with it. I know of jQuery's .live feature, but I cannot find a similar feature in Prototype. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To view this discussion on the web visit https://groups.google.com/d/msg/prototype-scriptaculous/-/3R9rCrWTjaIJ. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To
Re: [Proto-Scripty] Prototype, addClassName on future elements
Thank you very much. I will play around with the different solutions. On Wed, Oct 24, 2012 at 2:59 PM, Walter Lee Davis wa...@wdstudio.comwrote: DOM should be all caps. I just tried this in Safari 6, and while I couldn't get SubtreeModified to work, DOMNodeInserted worked great. You might want to try that. It works no matter what sort of content you insert -- even a bare string is a new DOM node. Walter On Oct 24, 2012, at 8:52 AM, Henrik Aagaard Sørensen wrote: PeriodicalExecuter does the job, thank you. However, I would like to try DomSubtreeModified. But this doesn't work in Chrome: document.observe('DomSubtreeModified ', function () { //Do stuff }); Am I doing something wrong? On Wed, Oct 24, 2012 at 2:47 PM, Walter Lee Davis wa...@wdstudio.com wrote: Okay, then try this (wasteful but should do the job): new PeriodicalExecuter(function(){ $$('.foo').invoke('addClassName', 'bar'); }, 0.3); There's also an event (not uniformly covered by the browsers) that is fired when a DOM element is changed. Try observing DomSubtreeModified and hooking off of that to fire your class modification. Walter On Oct 24, 2012, at 8:34 AM, Henrik Aagaard Sørensen wrote: Hi Walter. Thank you for your answer, however, I do not have the ability to change the Ajax-calls. It's external scripts which is being loaded. On Wed, Oct 24, 2012 at 2:32 PM, Walter Lee Davis wa...@wdstudio.com wrote: You can add this transformation in the onSuccess callback of your Ajax call: new Ajax.Updater('foo', '/get/more/foo', {onSuccess: function(){ $$('.foo').invoke('addClassName', 'bar'); }); As long as you don't have a ton of DOM changes happening, this should just work. Otherwise, you may want to wrap it in a Defer to ensure that the DOM is stable before you run it. Walter On Oct 24, 2012, at 8:00 AM, Henrik Aagaard Sørensen wrote: No, unfortunately it's not that. It's elements being loaded into the dom later. I'm already using dom:loaded and I've placed the JS jus before /body as the last element. However, there are several Ajax-calls which later (in the future, after everything is loaded) creates new elements (which I have no control over), so I need to have Prototype adding specific class-names in elements which fullfill CSS selector at all time. On Wed, Oct 24, 2012 at 1:57 PM, Walter Lee Davis wa...@wdstudio.com wrote: Can you describe what you mean by future elements on the page? Do you mean elements that are later in the source order than the script? If so, that's pretty simple: document.observe('dom:loaded', function(){ $$('div.foo').invoke('addClassName', 'bar'); }); Walter On Oct 24, 2012, at 7:52 AM, Henrik Aagaard Sørensen wrote: I'm trying to append a class via addClassName on future elements on a page with Prototype, however I do seem to struggle a bit with it. I know of jQuery's .live feature, but I cannot find a similar feature in Prototype. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To view this discussion on the web visit https://groups.google.com/d/msg/prototype-scriptaculous/-/3R9rCrWTjaIJ. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups
[Proto-Scripty] Transparency e Opacity don´t work in IE 8
Hi I'm using Prototype 1.2 And the transparency and opacity not work in ie8 My code: $('av-img').addEvent('mouseover', function(event){ $('avatar_upload').setStyle('background', 'rgba(0, 0, 0, 0.6)'); $('select-0').setStyle('color', '#fff'); }); $('av-img').addEvent('mouseout', function(event){ $('avatar_upload').setStyle('background', 'transparent'); $('select-0').setStyle('color', 'transparent'); }); $('avatar_upload').addEvent('mouseover', function(event){ $('avatar_upload').setStyle('background', 'rgba(0, 0, 0, 0.6)'); $('select-0').setStyle('color', '#fff'); }); $('avatar_upload').addEvent('mouseout', function(event){ $('avatar_upload').setStyle('background', 'rgba(0, 0, 0, 0.6)'); $('select-0').setStyle('color', '#fff'); }); How fix this bug? Tks -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To view this discussion on the web visit https://groups.google.com/d/msg/prototype-scriptaculous/-/MkGnHbV-4SwJ. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.