[Proto-Scripty] to NEW or not to NEW, that is the question
Which is more proper? new Effect.Fade(..) or Effect.Fade(..) Both work for me. I'm just wondering which one is more cross browser compatible or runs faster. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Typewriter effect
Is there a Scriptaculous effect to spell out a word slowy: S SE SEN SENT SENTE SENTEN SENTENCE And also delete it slowly? SENTENCE SENTENC SENTEN SENTE SENT SEN SE S --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: this keyword inside of the map function
Andy Daykin wrote: Hello, I am having some difficulties writing a class, in my code I have a class where I need to be able to bind event listeners to values. In my code I want the variable pointerIndex to be accessible outside of the initialize function, but right now it is not. If I make a global variable for pointerIndex I can solve the problem, but I would rather have a class variable using the this keyword. I am not positive, but I believe the problem is from my event listeners on the line: Now: $(e).observe('click', this.doSlide.bind(featuresWrapper[i].id)); Before: (working) $(e).observe('click', mySlide.doSlide.curry(featuresWrapper[i].id)); With the new way of calling the doSlide function I can't even seem to be able to call the function, nothing happens when the function should get called. Before I was using the curry function to try and pass the values of the featuresWrapper array to the doSlide function. I was able to get that to work, but I would rather just use bind and this to make the code more object oriented. Based on my alert statements I can tell that the this keyword is different inside and outside of the map function. Hi Andy, the last observation is crucial. Because this is not your expected SlideShow instance when you do this.doSlide.bind (...), this.doSlide is undefined and thus the call to this.doSlide.bind fails (there should be an exception in the error console somewhere). You can solve it by bind()-ing the map function, too: $(parentDiv).childElements().map( (function(e) { $(e).observe('click', this.doSlide.bind(this, featuresWrapper[i].id)); }).bind (this) ); (Note: Passing this as first arg to the inner bind call, as Kevin suggested, is needed, too.) Have fun Daniel var SlideShow = Class.create({ initialize: function(parentDiv) { this.pointerIndex = 0; //pointerIndex = 0; // Load the event listener for each section document.observe(dom:loaded, function() { var featuresWrapper = $('featuresWrapper').childElements(); var i = 0; alert(this); $(parentDiv).childElements().map(function(e) { alert(this); $(e).observe('click', this.doSlide.bind(featuresWrapper[i].id)); //$(e).observe('click', mySlide.doSlide.curry(featuresWrapper[i].id)); i++; }); slides = $$('.featureImage').map(function(e) { return e.id; }); }); }, doSlide: function(slideClicked) { alert('here'); if(active == 0) { active = 1; var yValCurrent = $(slides[this.pointerIndex]).viewportOffset().top; //var yValCurrent = $(slides[pointerIndex]).viewportOffset().top; var yValClick = $(slideClicked).viewportOffset().top; var yValDiff = yValClick - yValCurrent; var pointerShift = 0; if (Math.abs(yValDiff) == Math.abs(210)) { pointerShift = 70; // Change this to get the height as well as a few more } else { pointerShift = 140; } if (yValDiff 0) { $$('.featureImage').map(function(e) { new Effect.Move(e, { y: -yValDiff, duration: .8, afterFinish: function(e) { active = 0; } }); }); new Effect.Move('featurePointer', { y: pointerShift }); } else if (yValDiff 0) { $$('.featureImage').map(function(e) { new Effect.Move(e, { y: -yValDiff, duration: .8, afterFinish: function(e) { active = 0; } }); }); new Effect.Move('featurePointer', { y: -pointerShift }); } this.pointerIndex = slides.indexOf(slideClicked); } } }); var slides; var active = 0; //var pointerIndex = 0; var mySlide = new SlideShow('featureList'); --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] onclick functionality in ajax
I have set up a relatively straight forward scenario where i have a listener for event A. On click of A (a button), I run an ajax request to update a div B. B was a large div, representing one of 3 panels on a page. B had some javascript functionality (lets call this event C) inside of it which worked prior to clicking A, but after clicking A, it no longer works. I know this is a DOM issue, but I've got to think there is a good way around this. Any ideas? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: onclick functionality in ajax
Hi, When you replace an element, the old element is no longer displayed (ideally it no longer exists) and a new element is put in its place. Any event handlers associated with the old element are not automatically transferred to the new one. There are a couple of ways to handle this: 1. Event Delegation: If you can handle events on the container containing B, rather than on B itself, then you'll be fine since you're not replacing the container. Clicks and most other events bubble up from the child elements to their ancestors, so this can be a powerful approach. For instance, I have an app with a bunch of links that trigger client-side actions (rather than actually going somewhere). I don't look the click event on each link, that would be horribly inefficient. Instead, I hook the click event on the container all of these links are in, and then when I get the event I ask what link triggered it via Event#findElement[1]. 2. If event delegation won't work for you, you'll need to unhook all of your handlers on B before replacing it, then hook them up to the new B after replacing it. If you don't unhook your handlers before you replace B, you'll probably leak some memory on every update; and of course if you don't hook up the new handlers you won't see the clicks. [1] http://prototypejs.org/api/event/findElement HTH, -- T.J. Crowder tj / crowder software / com Independent Software Engineer, consulting services available On Aug 20, 12:19 am, hass dhasso...@gmail.com wrote: I have set up a relatively straight forward scenario where i have a listener for event A. On click of A (a button), I run an ajax request to update a div B. B was a large div, representing one of 3 panels on a page. B had some javascript functionality (lets call this event C) inside of it which worked prior to clicking A, but after clicking A, it no longer works. I know this is a DOM issue, but I've got to think there is a good way around this. Any ideas? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: onclick functionality in ajax
You need to re-observe the listeners Perhaps a pastie of your code would help us help you.. Alex Mcauley http://www.thevacancymarket.com - Original Message - From: hass dhasso...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Thursday, August 20, 2009 12:19 AM Subject: [Proto-Scripty] onclick functionality in ajax I have set up a relatively straight forward scenario where i have a listener for event A. On click of A (a button), I run an ajax request to update a div B. B was a large div, representing one of 3 panels on a page. B had some javascript functionality (lets call this event C) inside of it which worked prior to clicking A, but after clicking A, it no longer works. I know this is a DOM issue, but I've got to think there is a good way around this. Any ideas? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: to NEW or not to NEW, that is the question
new defines an new instance of an Object / class. Some things dont need new and some do. It has nothing to dow tih Cross browser afaik Alex Mcauley http://www.thevacancymarket.com - Original Message - From: Mojito tokyot...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Thursday, August 20, 2009 7:29 AM Subject: [Proto-Scripty] to NEW or not to NEW, that is the question Which is more proper? new Effect.Fade(..) or Effect.Fade(..) Both work for me. I'm just wondering which one is more cross browser compatible or runs faster. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: help with select on element not working
Hi Colin, Incidentally (and not on topic for your question) td/ is not valid in either HTML or XHTML. It's valid XHTML for an empty table cell. Wrong. It's a common misconception (which I had myself until recently). If so, it's a misconception the W3C's own validator shares. -- T.J. Crowder tj / crowder software / com Independent Software Engineer, consulting services available On Aug 19, 10:24 am, ColinFine colin.f...@pace.com wrote: On Aug 18, 4:47 pm, T.J. Crowder t...@crowdersoftware.com wrote: Colin, Incidentally (and not on topic for your question) td/ is not valid in either HTML or XHTML. It's valid XHTML for an empty table cell. Wrong. It's a common misconception (which I had myself until recently). All elements other than those declared in the DTD as EMPTY must have an end tag. Elements that are declared in the DTD as EMPTY can have an end tag or can use empty element shorthand (see Empty Elements). (http://www.w3.org/TR/2002/REC-xhtml1-20020801/#h-4.3) That is, elements DECLARED TO BE EMPTY may use the shorthand. Elements which happen to have no content may not. I discovered this when Firefox correctly objected to td/ or something when I had given it an XTHML-Strict DOCTYPE. Also, td does not have a 'type' attribute. I believe browsers generally do let you set an arbitrary attribute (though I haven't found anything in the HTML spec that explicitly permits it)... It is in fact verboten. Is it? I couldn't find an explicit statement that only the defined attributes were permitted, though it is implied (and I thought I had found somewhere in the HTML spec where it referred to 'attributes defined in this specification', which might be taken to imply that other attributes were permitted; but I can't find that now). In HTML5, though, we're allowed to use our own attributes as long as their names start with data-, e.g.: td data-foo='bar' ...is valid but td foo='bar' ...is not. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Using Ajax.Request and evalJS to load functions on the fly
Hi, Can you post a minimal, self-contained example[1] of the problem? [1] http://proto-scripty.wikidot.com/self-contained-test-page -- T.J. Crowder tj / crowder software / com Independent Software Engineer, consulting services available On Aug 19, 2:39 pm, Donnie Carvajal donnie.carva...@tfmx.com wrote: HI T.J., Will this work with Ajax.Request? I changed my script so that it is created instead of defined and I still can't access it using evalJS. Donnie -Original Message- From: prototype-scriptaculous@googlegroups.com [mailto:prototype-scriptacul...@googlegroups.com] On Behalf Of T.J. Crowder Sent: Tuesday, August 18, 2009 4:24 PM To: Prototype script.aculo.us Subject: [Proto-Scripty] Re: Using Ajax.Request and evalJS to load functions on the fly Hi, They're accessible from anywhere after they're evaluated, but mind how you declare them, because of a bit of a quirk about how they're evaluated. There's a badly misplaced note about this in the documentation, at the bottom of the discussion of Ajax.Updater[1]. It really should be in the String#evalScripts documentation, and it's on my list, but I haven't had a chance to move it. [1]http://prototypejs.org/api/ajax/updater HTH, -- T.J. Crowder tj / crowder software / com Independent Software Engineer, consulting services available On Aug 18, 8:00 pm, Remah donnie.carva...@tfmx.com wrote: I am trying to call a JS file using Ajax.Request that will return a javascript function. This function will be used by code taht will be injected into a div. Is this possible? It seems like the function is accessible within the CallBacks of Ajax.Request, but they are not accessible outside. Thanks for your help, Remah --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Prototype breaks the IE8 native JSON parser.
Hi, Wait! Stop the presses, are you saying IE8 has...a bug in it? ;-) (Oh, I shouldn't be mean to Microsoft, all browsers have bugs in them, and they seem to have made quite an effort in IE8.) Have you reported the bug to Microsoft? Seriously, though, thank you for doing the research to why it breaks and posting the info here, very very useful -- I'm sure you just saved the core team a fair bit of time hunting this down. -- T.J. Crowder tj / crowder software / com Independent Software Engineer, consulting services available On Aug 19, 9:58 pm, Joel joel.muel...@gmail.com wrote: See the following URL for all the gory details: http://stackoverflow.com/questions/1288962/ie8-native-json-parse-prot... But to sum up, the following test case will get an out of stack space error in IE8 when it is running in IE8 Standards mode (you can check the mode by hitting F12 for the Developer Tools). If you comment out either the Function.prototype line or the Array.prototype line, you won't get the error. Because Prototype adds functions to both Array.prototype and Function.prototype, pages that use Prototype will get the out of stack space error whenever they try to use the native JSON parser to parse some JSON that contains an array. But only if they pass a reviver function to the JSON.parse() method. Which, unfortunately, is pretty common in order to handle dates. !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd; html xmlns=http://www.w3.org/1999/xhtml; head title/title script type=text/javascript Function.prototype.test1 = function() { }; Array.prototype.test2 = function() { }; window.onload = function() { alert(JSON.parse('{ foo: [1,2,3] }', function(k,v) { return v; })); } /script /head body /body /html --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: to NEW or not to NEW, that is the question
Hi, In general, the correct thing is what the docs[1] say it is. Fade, Appear, and most others are just functions, not constructor functions, and so new is not correct. Some other things, like Effect.Opacity [2] (which confusingly use *exactly* the same capitalization -- don't shoot the messenger), are constructor functions, and so you need to use new with them. When in doubt, check the docs. I don't know scripty well enough to know why some of them are constructors and some aren't; perhaps there's a good reason... If you use the methodized form instead: $('myNiftyFadingElement').fade(); ...you don't have to worry about it. [1] http://wiki.github.com/madrobby/scriptaculous/effect-fade [1] http://wiki.github.com/madrobby/scriptaculous/effect-opacity HTH -- T.J. Crowder tj / crowder software / com Independent Software Engineer, consulting services available On Aug 20, 7:29 am, Mojito tokyot...@gmail.com wrote: Which is more proper? new Effect.Fade(..) or Effect.Fade(..) Both work for me. I'm just wondering which one is more cross browser compatible or runs faster. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: this keyword inside of the map function
Hi, Rather than binding it, use the second parameter to map (aka collect [1]), that's what the second param (context) is for. You'll find that most of the Enumerable methods that take callbacks also take a context parameter so the callback can be a method. [1] http://prototypejs.org/api/enumerable/collect HTH, -- T.J. Crowder tj / crowder software / com Independent Software Engineer, consulting services available On Aug 20, 8:34 am, Daniel Rubin dru...@dimedis.de wrote: Andy Daykin wrote: Hello, I am having some difficulties writing a class, in my code I have a class where I need to be able to bind event listeners to values. In my code I want the variable pointerIndex to be accessible outside of the initialize function, but right now it is not. If I make a global variable for pointerIndex I can solve the problem, but I would rather have a class variable using the this keyword. I am not positive, but I believe the problem is from my event listeners on the line: Now: $(e).observe('click', this.doSlide.bind(featuresWrapper[i].id)); Before: (working) $(e).observe('click', mySlide.doSlide.curry(featuresWrapper[i].id)); With the new way of calling the doSlide function I can't even seem to be able to call the function, nothing happens when the function should get called. Before I was using the curry function to try and pass the values of the featuresWrapper array to the doSlide function. I was able to get that to work, but I would rather just use bind and this to make the code more object oriented. Based on my alert statements I can tell that the this keyword is different inside and outside of the map function. Hi Andy, the last observation is crucial. Because this is not your expected SlideShow instance when you do this.doSlide.bind (...), this.doSlide is undefined and thus the call to this.doSlide.bind fails (there should be an exception in the error console somewhere). You can solve it by bind()-ing the map function, too: $(parentDiv).childElements().map( (function(e) { $(e).observe('click', this.doSlide.bind(this, featuresWrapper[i].id)); }).bind (this) ); (Note: Passing this as first arg to the inner bind call, as Kevin suggested, is needed, too.) Have fun Daniel var SlideShow = Class.create({ initialize: function(parentDiv) { this.pointerIndex = 0; //pointerIndex = 0; // Load the event listener for each section document.observe(dom:loaded, function() { var featuresWrapper = $('featuresWrapper').childElements(); var i = 0; alert(this); $(parentDiv).childElements().map(function(e) { alert(this); $(e).observe('click', this.doSlide.bind(featuresWrapper[i].id)); //$(e).observe('click', mySlide.doSlide.curry(featuresWrapper[i].id)); i++; }); slides = $$('.featureImage').map(function(e) { return e.id; }); }); }, doSlide: function(slideClicked) { alert('here'); if(active == 0) { active = 1; var yValCurrent = $(slides[this.pointerIndex]).viewportOffset().top; //var yValCurrent = $(slides[pointerIndex]).viewportOffset().top; var yValClick = $(slideClicked).viewportOffset().top; var yValDiff = yValClick - yValCurrent; var pointerShift = 0; if (Math.abs(yValDiff) == Math.abs(210)) { pointerShift = 70; // Change this to get the height as well as a few more } else { pointerShift = 140; } if (yValDiff 0) { $$('.featureImage').map(function(e) { new Effect.Move(e, { y: -yValDiff, duration: .8, afterFinish: function(e) { active = 0; } }); }); new Effect.Move('featurePointer', { y: pointerShift }); } else if (yValDiff 0) { $$('.featureImage').map(function(e) { new Effect.Move(e, { y: -yValDiff, duration: .8, afterFinish: function(e) { active = 0; } }); }); new Effect.Move('featurePointer', { y: -pointerShift }); } this.pointerIndex = slides.indexOf(slideClicked); } } }); var slides; var active = 0; //var pointerIndex = 0; var mySlide = new SlideShow('featureList'); --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Order in $H(responseJSON.Data)
I have a problem: from server I receive such JSON string (resp.responseJSON.Data) { Data: { ABC: 6, NUI: 1, ITM: 10 . } } where elements in Data have the apropriate order When I do $H(responseJSON.Data) - I have hash object with different order of elements But I need to have the original order of elements! What should I do and how can I get it? Help me please --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Prototype breaks the IE8 native JSON parser.
This is a Prototype bug and will be fixed in version 1.7. In the meantime, please use Object.toJSON(...) instead. Best, Tobie On Aug 20, 10:53 am, T.J. Crowder t...@crowdersoftware.com wrote: Hi, Wait! Stop the presses, are you saying IE8 has...a bug in it? ;-) (Oh, I shouldn't be mean to Microsoft, all browsers have bugs in them, and they seem to have made quite an effort in IE8.) Have you reported the bug to Microsoft? Seriously, though, thank you for doing the research to why it breaks and posting the info here, very very useful -- I'm sure you just saved the core team a fair bit of time hunting this down. -- T.J. Crowder tj / crowder software / com Independent Software Engineer, consulting services available On Aug 19, 9:58 pm, Joel joel.muel...@gmail.com wrote: See the following URL for all the gory details: http://stackoverflow.com/questions/1288962/ie8-native-json-parse-prot... But to sum up, the following test case will get an out of stack space error in IE8 when it is running in IE8 Standards mode (you can check the mode by hitting F12 for the Developer Tools). If you comment out either the Function.prototype line or the Array.prototype line, you won't get the error. Because Prototype adds functions to both Array.prototype and Function.prototype, pages that use Prototype will get the out of stack space error whenever they try to use the native JSON parser to parse some JSON that contains an array. But only if they pass a reviver function to the JSON.parse() method. Which, unfortunately, is pretty common in order to handle dates. !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd; html xmlns=http://www.w3.org/1999/xhtml; head title/title script type=text/javascript Function.prototype.test1 = function() { }; Array.prototype.test2 = function() { }; window.onload = function() { alert(JSON.parse('{ foo: [1,2,3] }', function(k,v) { return v; })); } /script /head body /body /html --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Order in $H(responseJSON.Data)
Hi Buda, you can't rely on browser internal way to store JSON. Each as its own way. The only thing you can do is to call a sort() function but in that case you'll also loose original order.** One thing I can propose is to modify data to have an numerical index to your data so calling a sort() function will give you the original order. Your data could look like that: { Data: { 1:{ABC: 6}, 2:{NUI: 1}, 3:{ITM: 10} . } } -- david On 20 août, 13:28, buda www...@pochta.ru wrote: I have a problem: from server I receive such JSON string (resp.responseJSON.Data) { Data: { ABC: 6, NUI: 1, ITM: 10 . } } where elements in Data have the apropriate order When I do $H(responseJSON.Data) - I have hash object with different order of elements But I need to have the original order of elements! What should I do and how can I get it? Help me please --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: ajax.request routine fails in IE
hi Im using here ie 6 and it works. but, in ie the dom is ready only when the document is loaded so sometimes refering to an element is impossible before the dom is loaded. try moving the function call to the onload: body onload=setVar('world'); div id=var/div /body On 8/20/09, david david.brill...@gmail.com wrote: Hi Milko, which version of IE, because I test it with IE6, and it wotks. -- david On 18 août, 18:18, milko mi...@kretschmann.nl wrote: Hello, I made an ajax-routine using request and json, which works fine under all browsers except under IE. For the sake of illustration I made a simplified version of this. The link is:http://www.cartesians.com/geefeenster/ajax_test.html It should show the text: Hello world. The code of the (php-) script being called in the routine - ajax_test.php - is as follows: ?php $data['result'] = 'Hello '.$_GET['par']; header('X-JSON: (' . json_encode($data) . ')'); header('Content-type: application/x-json'); echo json_encode($data); ? Can anyone tell why this does not work under IE and what to do to make it work. Many thanks in advance. Milko Kretschmann. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: ajax.request routine fails in IE
Hi Milko, which version of IE, because I test it with IE6, and it wotks. -- david On 18 août, 18:18, milko mi...@kretschmann.nl wrote: Hello, I made an ajax-routine using request and json, which works fine under all browsers except under IE. For the sake of illustration I made a simplified version of this. The link is:http://www.cartesians.com/geefeenster/ajax_test.html It should show the text: Hello world. The code of the (php-) script being called in the routine - ajax_test.php - is as follows: ?php $data['result'] = 'Hello '.$_GET['par']; header('X-JSON: (' . json_encode($data) . ')'); header('Content-type: application/x-json'); echo json_encode($data); ? Can anyone tell why this does not work under IE and what to do to make it work. Many thanks in advance. Milko Kretschmann. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Order in $H(responseJSON.Data)
Or better, yet, use an array. On Aug 20, 2:06 pm, david david.brill...@gmail.com wrote: Hi Buda, you can't rely on browser internal way to store JSON. Each as its own way. The only thing you can do is to call a sort() function but in that case you'll also loose original order.** One thing I can propose is to modify data to have an numerical index to your data so calling a sort() function will give you the original order. Your data could look like that: { Data: { 1:{ABC: 6}, 2:{NUI: 1}, 3:{ITM: 10} . } } -- david On 20 août, 13:28, buda www...@pochta.ru wrote: I have a problem: from server I receive such JSON string (resp.responseJSON.Data) { Data: { ABC: 6, NUI: 1, ITM: 10 . } } where elements in Data have the apropriate order When I do $H(responseJSON.Data) - I have hash object with different order of elements But I need to have the original order of elements! What should I do and how can I get it? Help me please --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: help with select on element not working
On Aug 20, 9:39 am, T.J. Crowder t...@crowdersoftware.com wrote: Hi Colin, Incidentally (and not on topic for your question) td/ is not valid in either HTML or XHTML. It's valid XHTML for an empty table cell. Wrong. It's a common misconception (which I had myself until recently). If so, it's a misconception the W3C's own validator shares. You're right. How bizarre. The spec clearly says no. I'm sure I discovered this restriction because Firefox objected once, but I can't think in what context. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] effect.multiple and effect.scale
Hi, I run this line : Effect.multiple( tab, Effect.Scale); There are no effect. tab is an an array with two div elements. I run this line Effect.multiple( tab, Effect.Fade ); It's ok; Why ? Thanks, Bernard --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Ajax requests again
earlier on in the month i posted on how to do some things with Ajax requests genericaly like adding a loading message to all requests and i got a couple of responses but not many. I've been giving it alot of thought and i cam up with addMethods as a way to add some things to the Ajax Class... Could anyone give me an example of how to do this with addMethods - just a hello world will do then i can take it from there Much appreciated in advance Alex --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Prototype breaks the IE8 native JSON parser.
Tobie, What's the issue #? I'm curious how Prototype can work around this IE8 behavior... Cheers, -- T.J. On Aug 20, 1:04 pm, Tobie Langel tobie.lan...@gmail.com wrote: This is a Prototype bug and will be fixed in version 1.7. In the meantime, please use Object.toJSON(...) instead. Best, Tobie On Aug 20, 10:53 am, T.J. Crowder t...@crowdersoftware.com wrote: Hi, Wait! Stop the presses, are you saying IE8 has...a bug in it? ;-) (Oh, I shouldn't be mean to Microsoft, all browsers have bugs in them, and they seem to have made quite an effort in IE8.) Have you reported the bug to Microsoft? Seriously, though, thank you for doing the research to why it breaks and posting the info here, very very useful -- I'm sure you just saved the core team a fair bit of time hunting this down. -- T.J. Crowder tj / crowder software / com Independent Software Engineer, consulting services available On Aug 19, 9:58 pm, Joel joel.muel...@gmail.com wrote: See the following URL for all the gory details: http://stackoverflow.com/questions/1288962/ie8-native-json-parse-prot... But to sum up, the following test case will get an out of stack space error in IE8 when it is running in IE8 Standards mode (you can check the mode by hitting F12 for the Developer Tools). If you comment out either the Function.prototype line or the Array.prototype line, you won't get the error. Because Prototype adds functions to both Array.prototype and Function.prototype, pages that use Prototype will get the out of stack space error whenever they try to use the native JSON parser to parse some JSON that contains an array. But only if they pass a reviver function to the JSON.parse() method. Which, unfortunately, is pretty common in order to handle dates. !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd; html xmlns=http://www.w3.org/1999/xhtml; head title/title script type=text/javascript Function.prototype.test1 = function() { }; Array.prototype.test2 = function() { }; window.onload = function() { alert(JSON.parse('{ foo: [1,2,3] }', function(k,v) { return v; })); } /script /head body /body /html --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Automatically Converting HTML to DOM (e.g. new Element ...)
Unlikely. There is very little difference in computation effort between generating JSON, XML, HTML or delimited text at the server. I will have to take your word for this. I assumed it to be different. So why put it in two places? Why turn data into say JSON just so you can later turn it into HTML? Just create HTML in the first place using a template on the server. It would only really only be in one place - client side scripting. The JSON would be a single line. The greatest time taken is in getting the data from the server, which will be (pretty much) the same regardless of how the data is formatted. If it takes place client-side, the client doesn't need to wait for data to come back from the server before the new items are displayed. They are displayed right away while data is sent back to the server to be saved. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: POSTing a form via AJAX
T.J. Crowder wrote: Hi, 'Tis indeed very easy. Say you have a form wrapped in a div: div id='formwrapper'form /form/div You can post it like so and take the result (which is presumed to be an HTML snippet in this case) and use that to update the container: new Ajax.Updater('formwrapper', someurl, { parameters: $('formwrapper').down('form').serialize(true), onFailure: function(response) { // ...show a failure message... } }); ... That seemed so easy when I read the post, but. . . How do I trigger the submission ? I tried onsubmit = {the code above} and it just submitted regularly and replaced the whole page with the output, not just the div. I tried putting the code above as a script after the form, but still in the div and got the same result. bill -- Bill Drescher william {at} TechServSys {dot} com --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: POSTing a form via AJAX
Bill You need to observe the form submit. $('the-id-of-the-form').observe('submit',function(event) { /// do the ajax that TJ said... Event.stop(event); // will stop it doing its default action! }); Alex Mcauley http://www.thevacancymarket.com - Original Message - From: bill To: prototype-scriptaculous@googlegroups.com Sent: Thursday, August 20, 2009 4:14 PM Subject: [Proto-Scripty] Re: POSTing a form via AJAX T.J. Crowder wrote: Hi, 'Tis indeed very easy. Say you have a form wrapped in a div: div id='formwrapper'form /form/div You can post it like so and take the result (which is presumed to be an HTML snippet in this case) and use that to update the container: new Ajax.Updater('formwrapper', someurl, { parameters: $('formwrapper').down('form').serialize(true), onFailure: function(response) { // ...show a failure message... } }); ... That seemed so easy when I read the post, but. . . How do I trigger the submission ? I tried onsubmit = {the code above} and it just submitted regularly and replaced the whole page with the output, not just the div. I tried putting the code above as a script after the form, but still in the div and got the same result. bill -- Bill Drescher william {at} TechServSys {dot} com --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: POSTing a form via AJAX
bill wrote: T.J. Crowder wrote: Hi, 'Tis indeed very easy. Say you have a form wrapped in a div: div id='formwrapper'form /form/div You can post it like so and take the result (which is presumed to be an HTML snippet in this case) and use that to update the container: new Ajax.Updater('formwrapper', someurl, { parameters: $('formwrapper').down('form').serialize(true), onFailure: function(response) { // ...show a failure message... } }); ... That seemed so easy when I read the post, but. . . How do I trigger the submission ? I tried onsubmit = {the code above} and it just submitted regularly and replaced the whole page with the output, not just the div. I tried putting the code above as a script after the form, but still in the div and got the same result. bill Putting the code as a script did not work, I expect, because the script was not served by Ajax.updater. Using Firebug I determined that the script was stripped out, which raises the next question. I know that I need to set a parameter to updater so that it will not strip scripts. I have read the section on evalScripts and the need to set the function with coolFunc = function () { ... } The script that loads the form is invoked as: new Ajax.Updater('showMessageDiv',url , {method: 'get',evalScripts: true} ); // get the requested message where url is defined as: url = 'mail/getmessage.php?n=' + message_id; but it does not upload the script so I suspect that I have the evalScripts in the wrong place. -- Bill Drescher william {at} TechServSys {dot} com --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Automatically Converting HTML to DOM (e.g. new Element ...)
Yes if your roundtrip is slow then doing it clientside can make it seem more responsive. There is the issue though of what happens if the server save fails? Revert your changes? Overall using serverside output is less troublesome, easier to code, and more robust. On 8/20/09, drewB dbats...@gmail.com wrote: Unlikely. There is very little difference in computation effort between generating JSON, XML, HTML or delimited text at the server. I will have to take your word for this. I assumed it to be different. So why put it in two places? Why turn data into say JSON just so you can later turn it into HTML? Just create HTML in the first place using a template on the server. It would only really only be in one place - client side scripting. The JSON would be a single line. The greatest time taken is in getting the data from the server, which will be (pretty much) the same regardless of how the data is formatted. If it takes place client-side, the client doesn't need to wait for data to come back from the server before the new items are displayed. They are displayed right away while data is sent back to the server to be saved. -- Sent from my mobile device --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: help with select on element not working
Thanks, Colin, glad it was something like that. -- T.J. :-) On Aug 20, 5:43 pm, ColinFine colin.f...@pace.com wrote: On Aug 20, 9:39 am, T.J. Crowder t...@crowdersoftware.com wrote: Hi Colin, Incidentally (and not on topic for your question) td/ is not valid in either HTML or XHTML. It's valid XHTML for an empty table cell. Wrong. It's a common misconception (which I had myself until recently). If so, it's a misconception the W3C's own validator shares. Apologies - I was wrong. After discussion with somebody from W3C I now understand that the section I was quoting is informative not normative. I do think that it is misleading however (and I'm sure I discovered this apparent limitation when something - I thought it was firefox - threw out a construct like div/). Both the XML and XHTML specs recommend not using the short form for elements which are not defined as EMPTY, but they do not forbid it. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: this keyword inside of the map function
I tried the first suggestion, but the function still isn't getting called. TJ, can you explain more, or show an example of what the context param would look like? Should I just put the doSlide function as the 2nd parameter? -Andy -- From: T.J. Crowder t...@crowdersoftware.com Sent: Thursday, August 20, 2009 3:56 AM To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Subject: [Proto-Scripty] Re: this keyword inside of the map function Hi, Rather than binding it, use the second parameter to map (aka collect [1]), that's what the second param (context) is for. You'll find that most of the Enumerable methods that take callbacks also take a context parameter so the callback can be a method. [1] http://prototypejs.org/api/enumerable/collect HTH, -- T.J. Crowder tj / crowder software / com Independent Software Engineer, consulting services available On Aug 20, 8:34 am, Daniel Rubin dru...@dimedis.de wrote: Andy Daykin wrote: Hello, I am having some difficulties writing a class, in my code I have a class where I need to be able to bind event listeners to values. In my code I want the variable pointerIndex to be accessible outside of the initialize function, but right now it is not. If I make a global variable for pointerIndex I can solve the problem, but I would rather have a class variable using the this keyword. I am not positive, but I believe the problem is from my event listeners on the line: Now: $(e).observe('click', this.doSlide.bind(featuresWrapper[i].id)); Before: (working) $(e).observe('click', mySlide.doSlide.curry(featuresWrapper[i].id)); With the new way of calling the doSlide function I can't even seem to be able to call the function, nothing happens when the function should get called. Before I was using the curry function to try and pass the values of the featuresWrapper array to the doSlide function. I was able to get that to work, but I would rather just use bind and this to make the code more object oriented. Based on my alert statements I can tell that the this keyword is different inside and outside of the map function. Hi Andy, the last observation is crucial. Because this is not your expected SlideShow instance when you do this.doSlide.bind (...), this.doSlide is undefined and thus the call to this.doSlide.bind fails (there should be an exception in the error console somewhere). You can solve it by bind()-ing the map function, too: $(parentDiv).childElements().map( (function(e) { $(e).observe('click', this.doSlide.bind(this, featuresWrapper[i].id)); }).bind (this) ); (Note: Passing this as first arg to the inner bind call, as Kevin suggested, is needed, too.) Have fun Daniel var SlideShow = Class.create({ initialize: function(parentDiv) { this.pointerIndex = 0; //pointerIndex = 0; // Load the event listener for each section document.observe(dom:loaded, function() { var featuresWrapper = $('featuresWrapper').childElements(); var i = 0; alert(this); $(parentDiv).childElements().map(function(e) { alert(this); $(e).observe('click', this.doSlide.bind(featuresWrapper[i].id)); //$(e).observe('click', mySlide.doSlide.curry(featuresWrapper[i].id)); i++; }); slides = $$('.featureImage').map(function(e) { return e.id; }); }); }, doSlide: function(slideClicked) { alert('here'); if(active == 0) { active = 1; var yValCurrent = $(slides[this.pointerIndex]).viewportOffset().top; //var yValCurrent = $(slides[pointerIndex]).viewportOffset().top; var yValClick = $(slideClicked).viewportOffset().top; var yValDiff = yValClick - yValCurrent; var pointerShift = 0; if (Math.abs(yValDiff) == Math.abs(210)) { pointerShift = 70; // Change this to get the height as well as a few more } else { pointerShift = 140; } if (yValDiff 0) { $$('.featureImage').map(function(e) { new Effect.Move(e, { y: -yValDiff, duration: .8, afterFinish: function(e) { active = 0; } }); }); new Effect.Move('featurePointer', { y: pointerShift }); } else if (yValDiff 0) { $$('.featureImage').map(function(e) { new Effect.Move(e, { y: -yValDiff, duration: .8, afterFinish: function(e) { active = 0; } }); }); new Effect.Move('featurePointer', { y: -pointerShift }); } this.pointerIndex = slides.indexOf(slideClicked); } } }); var slides; var active = 0; //var pointerIndex = 0; var mySlide = new SlideShow('featureList'); --~--~-~--~~~---~--~~ 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,
[Proto-Scripty] Re: Div Fades
Jason. How are you calling these functions ? Are you using an a tag by any chance Alex Mcauley http://www.thevacancymarket.com - Original Message - From: Jason Frisvold xenopha...@gmail.com To: prototype-scriptaculous@googlegroups.com Sent: Thursday, August 20, 2009 9:17 PM Subject: [Proto-Scripty] Div Fades Hi there, I'm using appear and fade with a hidden div to display additional information about data in a table. This all works wonderfully with one caveat. Whenever the fade is called, the page jumps to the top, making the user have to scroll back down again. Am I doing something incorrectly, or do I need to compensate for this jump? Firefox 3.5, Prototype 1.6.0.3, Scriptaculous 1.8.2 The div is defined as follows : div id='hoverdiv' style='display:none; position:absolute; top:0; left:0;'/div My ajax calls are as follows : function showPopup(myItem, detailType, id) { myDiv = $('hoverdiv'); myItem = $(myItem); new Ajax.Updater('hoverdiv', 'getinfo.php?type=' + detailType + 'id=' + id, { method: 'get', onComplete: function() { var myOff = myItem.cumulativeOffset(); var newX = myOff[0] + (myItem.getWidth() - myDiv.getWidth()) / 2; var newY = myOff[1] + (myItem.getHeight() - myDiv.getHeight()) / 2; myDiv.style.top = newY + 'px'; myDiv.style.left = newX + 'px'; myDiv.appear(); } }); } function hidePopup(myDiv) { myDiv = $('hoverdiv'); myDiv.fade(); } -- --- Jason Frisvold xenopha...@gmail.com --- I love deadlines. I like the whooshing sound they make as they fly by. - Douglas Adams --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---