[Proto-Scripty] Re: Do somthing only after two Ajax calls return results
I have two calls run asyncronously Two - is an example - they may be N-calls :) I'd recommend avoiding that unless the async calls are to *different* servers, and if you do two at once, certainly never do more than two at once. Run just a single async request at a time, two if you absolutely have to, and chain them using the `success` handler. Why? Because browsers (and some servers) clamp down the number of connections to a given server at the same time. Mostly, with modern desktop browsers, you can expect the browser will allow four[1] (up from the previous figure of two), but IE will drop down to only allowing two if it detects a dial-up connection and you don't know what the next dot rev of any browser may do. Also, mobile browsers have lower limits. In terms of mechanism, I'd probably have a pending count (no need for global variables): * * * * // Start the requests defined in the array `requests`, call `callback` // when they've all finished. function sendMultipleRequests(requests, callback) { var req, pending; // Prep and start each request. We assume the objects have a `url` // property and a `params` property. pending = 0; while (pending requests.length) { // Get this request req = requests[pending]; // Hook into the onComplete, respecting the previous one if any req.params = req.params || {}; req.params.onComplete = req.params.onComplete ? req.params.onComplete.wrap(reqComplete) : reqComplete; // Start and count this request new Ajax.Request(req.url, req.params); ++pending; } function reqComplete() { --pending; if (pending = 0) { // All done, call the callback. // Note that there's no race condition with the loop above (e.g., // there's no possibility we'll be called and decrement `pending` // to 0 while the loop above is still incrementing it) because // JavaScript on browsers is single-threaded unless you explicitly // use the web workers stuff, which we aren't. callback(); } } } [1] http://www.stevesouders.com/blog/2008/03/20/roundup-on-parallel-connections/ HTH, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Nov 21, 8:40 pm, buda www...@pochta.ru wrote: I have two calls run asyncronously I need to wait when they both is comleted and only then do somthing Two - is an example - they may be N-calls :) What is the right method to do it? Is theere an object somthing AsyncWaitFor(AjaxCall1...AjaxCallN)? -- 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-scriptacul...@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: How to create math manipulatives
ain't working means nothing. What happens? What do you expect to happen? Also... I've never heard of onforminput (I'm not familiar with HTML5) but I think it's premature to be using HTML5 facilities unless you know which browsers your users will be using. In any case, it is at least being discussed to remove it. (http://lists.w3.org/Archives/Public/ public-webapps/2010OctDec/0183.html) I don't know why you are posting this on a prototype-scriptaculous list, since you appear to use neither in your script. Colin -- 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-scriptacul...@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] Do somthing only after two Ajax calls return results
var watcher = { watching: false, start: function() { watching = true; Ajax.Responders.register({ onComplete: function() { if ( watching Ajax.activeRequestCount == 0 ) { finalize(); } } }); stop: function() { watching = false; } }; // start your requests, then watcher.start(); function finalize() { watcher.stop(); // do other stuff } From: prototype-scriptaculous@googlegroups.com [mailto:prototype-scriptacul...@googlegroups.com] On Behalf Of Daff Niles Sent: Sunday, November 21, 2010 8:10 PM To: prototype-scriptaculous@googlegroups.com Subject: Re: [Proto-Scripty] Do somthing only after two Ajax calls return results Hi Buda, Having had this issue, and seen other frameworks sorting this out, the quickest and easiest way I have found is to have to global variables (flags) in the page, one for each of the Ajax calls. The Ajax callback method for each then sets the flag for that call back, then checks if both flags have been set, and if so, calls the function of your choice that will then continue the processing you desire. Because each callback only sets its own flag, but then checks both, it will not matter which order they callbacks are received and processed. pseudo code (untested) var flag_1 = false; var flag_2 = false; function callback_function_1() { // Processing... flag_1 = true; if(flag_1 flag_2) { // Call final method... finalize() } } function callback_function_2() { // Processing... flag_2 = true; if(flag_1 flag_2) { // Call final method... finalize() } } function finalize () { // Complete processing here... // If we need to call again, then reset the two flags in here... } Hope that helps. Regards. daff SOFTWARE ENGINEER andrew 'daff' niles | spidertracks | 117a the square po box 5203 | palmerston north 4441 | new zealand P: +64 6 353 3395 | M: +64 21 51 55 48 E: d...@spidertracks.co.nz www.spidertracks.com http://www.spidertracks.com/ On 22/11/2010, at 9:40 AM, buda wrote: I have two calls run asyncronously I need to wait when they both is comleted and only then do somthing Two - is an example - they may be N-calls :) What is the right method to do it? Is theere an object somthing AsyncWaitFor(AjaxCall1...AjaxCallN)? -- 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-scriptacul...@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-scriptacul...@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-scriptacul...@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] Re: How to create math manipulatives
You can use Form.Observer to watch for changes to any values in a form. This assumes you have assigned the name attribute to each of your form fields. Without that, the getValue calls will return nothing. See http://www.prototypejs.org/api/timedObserver/form-observer for more details. Something a bit puzzling though is why your onchange is not working. If using Event.observe(element,event,function), keep in mind that the names of the events are change, click, mouseover, . and not onchange, onclick. Event.observe(myButton,click, function() { alert(Leroy was here); }); Or myButton.onclick = function() { alert(Leroy was here); } From: prototype-scriptaculous@googlegroups.com [mailto:prototype-scriptacul...@googlegroups.com] On Behalf Of Amrutha Krishnan Sent: Friday, November 19, 2010 10:42 PM To: prototype-scriptaculous@googlegroups.com Subject: Re: [Proto-Scripty] Re: How to create math manipulatives Well I am creating a small app. to help you understand what I am looking for attaching a screen shot of my design. So basically as seen in the design there are two sections in the right section you enter numbers and even a slight change in that number must reflect in the answer. In the left there again there are 2 compartments for tens and untits, tens coulumn has 9 sub-columns and units has 9 sub-columns. Difference between them will b in the images displayed in tens you will see a bunch of 10 of a certain object(in each sub-column) whereas in units you will find only a single object in each sub-column. Now with a slight change in the right colums there should be an instant change in the images displayed on the left. I want an effect like shown by the onforminput event in HTML5. But somehow this even aint working when I use it so I have to use onchange instead. This does not help much because it eliminates the counting part from the answer displayed which is very crucial. Change from addition1.jpg screen to addition2.jpg screen needs to very quick On Fri, Nov 19, 2010 at 5:15 PM, ColinFine colin.f...@pace.com wrote: On Nov 18, 4:14 am, clumsy7 writetoamru...@gmail.com wrote: Hey guys I am creating an application to help teach kids basic math. In my application the screen is divided in to 2 parts the right part is to enter number, the left part is a dynamic visual representation of whats happening on the right)the kid can enter values in the text boxes on the right (initally the values in the 2 textboxes will be 0). My code is below and need help with it. Please help! If you would care to give an indication of what it is that you need help with, you are more likely to get that help. Is something not working? (If so, what, and how?) Is there something you'd like to add to it but don't know how to make it work? What? -- 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-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com mailto:prototype-scriptaculous%2bunsubscr...@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-scriptacul...@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-scriptacul...@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] Do somthing only after two Ajax calls return results
Forgot to unregister the responder. See revised watcher: var watcher = { start: function() { Ajax.Responders.register(responder); }, stop: function() { Ajax.Responders.unregister(responder); }, responder: { onComplete: function() { if ( Ajax.activeRequestCount == 0 ) { finalize(); } } } }; From: prototype-scriptaculous@googlegroups.com [mailto:prototype-scriptacul...@googlegroups.com] On Behalf Of Brian Marquis Sent: Monday, November 22, 2010 9:43 AM To: prototype-scriptaculous@googlegroups.com Subject: RE: [Proto-Scripty] Do somthing only after two Ajax calls return results var watcher = { watching: false, start: function() { watching = true; Ajax.Responders.register({ onComplete: function() { if ( watching Ajax.activeRequestCount == 0 ) { finalize(); } } }); stop: function() { watching = false; } }; // start your requests, then watcher.start(); function finalize() { watcher.stop(); // do other stuff } From: prototype-scriptaculous@googlegroups.com [mailto:prototype-scriptacul...@googlegroups.com] On Behalf Of Daff Niles Sent: Sunday, November 21, 2010 8:10 PM To: prototype-scriptaculous@googlegroups.com Subject: Re: [Proto-Scripty] Do somthing only after two Ajax calls return results Hi Buda, Having had this issue, and seen other frameworks sorting this out, the quickest and easiest way I have found is to have to global variables (flags) in the page, one for each of the Ajax calls. The Ajax callback method for each then sets the flag for that call back, then checks if both flags have been set, and if so, calls the function of your choice that will then continue the processing you desire. Because each callback only sets its own flag, but then checks both, it will not matter which order they callbacks are received and processed. pseudo code (untested) var flag_1 = false; var flag_2 = false; function callback_function_1() { // Processing... flag_1 = true; if(flag_1 flag_2) { // Call final method... finalize() } } function callback_function_2() { // Processing... flag_2 = true; if(flag_1 flag_2) { // Call final method... finalize() } } function finalize () { // Complete processing here... // If we need to call again, then reset the two flags in here... } Hope that helps. Regards. daff SOFTWARE ENGINEER andrew 'daff' niles | spidertracks | 117a the square po box 5203 | palmerston north 4441 | new zealand P: +64 6 353 3395 | M: +64 21 51 55 48 E: d...@spidertracks.co.nz www.spidertracks.com http://www.spidertracks.com/ On 22/11/2010, at 9:40 AM, buda wrote: I have two calls run asyncronously I need to wait when they both is comleted and only then do somthing Two - is an example - they may be N-calls :) What is the right method to do it? Is theere an object somthing AsyncWaitFor(AjaxCall1...AjaxCallN)? -- 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-scriptacul...@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-scriptacul...@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-scriptacul...@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-scriptacul...@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.Updater HTML Entities
Hello, I use Prototype 1.6 in conjunction with Smarty 3. I habe also a MySql DB with several columns that contains chars like or others that can be encoded with the php function: htmlentities I do not want to do a htmlentities before DB insert. The DB should contain no entitites just real text! The values comes from the DB trough Smarty, which transform them in their entity codes to have save display. The problem is, that if the HTML generated by Smarty website contains the correct entities. But if I use the response in Prototype's Ajax.Updater the entities afterwards are decoded. Is there a way to disable it? Like the evalJS parameter to avoid JS execution in ajax responses. Or is this a bug? -- 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-scriptacul...@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: Do somthing only after two Ajax calls return results
Thanks! This is what I need On 22 ноя, 12:15, T.J. Crowder t...@crowdersoftware.com wrote: I have two calls run asyncronously Two - is an example - they may be N-calls :) I'd recommend avoiding that unless the async calls are to *different* servers, and if you do two at once, certainly never do more than two at once. Run just a single async request at a time, two if you absolutely have to, and chain them using the `success` handler. Why? Because browsers (and some servers) clamp down the number of connections to a given server at the same time. Mostly, with modern desktop browsers, you can expect the browser will allow four[1] (up from the previous figure of two), but IE will drop down to only allowing two if it detects a dial-up connection and you don't know what the next dot rev of any browser may do. Also, mobile browsers have lower limits. In terms of mechanism, I'd probably have a pending count (no need for global variables): * * * * // Start the requests defined in the array `requests`, call `callback` // when they've all finished. function sendMultipleRequests(requests, callback) { var req, pending; // Prep and start each request. We assume the objects have a `url` // property and a `params` property. pending = 0; while (pending requests.length) { // Get this request req = requests[pending]; // Hook into the onComplete, respecting the previous one if any req.params = req.params || {}; req.params.onComplete = req.params.onComplete ? req.params.onComplete.wrap(reqComplete) : reqComplete; // Start and count this request new Ajax.Request(req.url, req.params); ++pending; } function reqComplete() { --pending; if (pending = 0) { // All done, call the callback. // Note that there's no race condition with the loop above (e.g., // there's no possibility we'll be called and decrement `pending` // to 0 while the loop above is still incrementing it) because // JavaScript on browsers is single-threaded unless you explicitly // use the web workers stuff, which we aren't. callback(); } } } [1]http://www.stevesouders.com/blog/2008/03/20/roundup-on-parallel-conne... HTH, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Nov 21, 8:40 pm, buda www...@pochta.ru wrote: I have two calls run asyncronously I need to wait when they both is comleted and only then do somthing Two - is an example - they may be N-calls :) What is the right method to do it? Is theere an object somthing AsyncWaitFor(AjaxCall1...AjaxCallN)? -- 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-scriptacul...@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: Do somthing only after two Ajax calls return results
This is not sutable because inparallel maybe run othes async calls which I dont need wait to complete On 22 ноя, 18:04, Brian Marquis br...@quotepro.com wrote: Forgot to unregister the responder. See revised watcher: var watcher = { start: function() { Ajax.Responders.register(responder); }, stop: function() { Ajax.Responders.unregister(responder); }, responder: { onComplete: function() { if ( Ajax.activeRequestCount == 0 ) { finalize(); } } } }; From: prototype-scriptaculous@googlegroups.com [mailto:prototype-scriptacul...@googlegroups.com] On Behalf Of Brian Marquis Sent: Monday, November 22, 2010 9:43 AM To: prototype-scriptaculous@googlegroups.com Subject: RE: [Proto-Scripty] Do somthing only after two Ajax calls return results var watcher = { watching: false, start: function() { watching = true; Ajax.Responders.register({ onComplete: function() { if ( watching Ajax.activeRequestCount == 0 ) { finalize(); } } }); stop: function() { watching = false; } }; // start your requests, then watcher.start(); function finalize() { watcher.stop(); // do other stuff } From: prototype-scriptaculous@googlegroups.com [mailto:prototype-scriptacul...@googlegroups.com] On Behalf Of Daff Niles Sent: Sunday, November 21, 2010 8:10 PM To: prototype-scriptaculous@googlegroups.com Subject: Re: [Proto-Scripty] Do somthing only after two Ajax calls return results Hi Buda, Having had this issue, and seen other frameworks sorting this out, the quickest and easiest way I have found is to have to global variables (flags) in the page, one for each of the Ajax calls. The Ajax callback method for each then sets the flag for that call back, then checks if both flags have been set, and if so, calls the function of your choice that will then continue the processing you desire. Because each callback only sets its own flag, but then checks both, it will not matter which order they callbacks are received and processed. pseudo code (untested) var flag_1 = false; var flag_2 = false; function callback_function_1() { // Processing... flag_1 = true; if(flag_1 flag_2) { // Call final method... finalize() } } function callback_function_2() { // Processing... flag_2 = true; if(flag_1 flag_2) { // Call final method... finalize() } } function finalize () { // Complete processing here... // If we need to call again, then reset the two flags in here... } Hope that helps. Regards. daff SOFTWARE ENGINEER andrew 'daff' niles | spidertracks | 117a the square po box 5203 | palmerston north 4441 | new zealand P: +64 6 353 3395 | M: +64 21 51 55 48 E: d...@spidertracks.co.nz www.spidertracks.com http://www.spidertracks.com/ On 22/11/2010, at 9:40 AM, buda wrote: I have two calls run asyncronously I need to wait when they both is comleted and only then do somthing Two - is an example - they may be N-calls :) What is the right method to do it? Is theere an object somthing AsyncWaitFor(AjaxCall1...AjaxCallN)? -- 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-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group athttp://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-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group athttp://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-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group athttp://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-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at
[Proto-Scripty] Re: Extending a DOM-Object
Thank you Mr Crowder, that was quite informative. Still I'm a little unsure how to proceed. If I got this right, it is common sense now that extending the DOM is the wrong thing to do. One of the main reasons is the possibility of name-conflicts. So I thought I might extend Objects with a JSON-Object (called 'builder' in my case) which contains all my methods and properties to (sort of) have my own namespace. But that would require a circular reference in my builder-object to the DOM-Element it is attached to (so the methods in my builder-object can work on the DOM they are attached to). I'm wondering if there's any way to keep that nice programming- paradigm prototype introduced with it's $-function, that you can simply write $('myelement').myfunction() while avoiding the above- mentioned problems. I could write my own wrapper-method, like jQuery's $-function, but that would miss the whole point of working with prototype. How do other people work with this? Luke On Nov 22, 7:37 am, T.J. Crowder t...@crowdersoftware.com wrote: Hi Luke, What you're talking about doing is called an expando property. They're not covered by a standard AFAIK, although interestingly Microsoft has an `expando` property on objects[1] (this is where the name came from) which is a boolean saying whether you can do this. If you do a web search on expando you'll find a lot more information (and a studio album by Timothy B. Schmit, but leave that aside...). (Ignore the statement on GreaseSpot that expandos relate to custom attributes; they don't, the article is just wrong.) Prototype uses expando properties like mad (the whole concept of extending an element[2] relies on expandos, and Prototype uses them elsewhere as well), so if you're using Prototype, you're already relying on the environment allowing expandos. But it's probably worth noting that Prototype is moving away from expandos at some point in favor of doing a jQuery-like wrapper thing instead. I'd avoid having your expando property value (directly or indirectly) reference another DOM element, as that sets up the possibility of circular references, and circular references that dip between the DOM and JavaScript layers can cause memory leaks on IE. [1]http://msdn.microsoft.com/en-us/library/ms533747(VS.85).aspx [2]http://prototypejs.org/learn/extensions Happy coding, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Nov 21, 8:28 pm, Luke kickingje...@gmail.com wrote: Thanks Walter. If that's the only reason I'm willing to take that risk. In my whole application I will only attach one variable, kind of like my namespace and this will give me some convenience when accessing that namespace. If it's conform to W3C standards and works in all browsers, I think it's ok. But is it? Can't find any documentation or specification on this Luke On Nov 21, 8:50 pm, Walter Lee Davis wa...@wdstudio.com wrote: I think that the basic reason for the separate store is to provide insulation from any current, past, or future browsers tramping on a key name you may choose today and test in some subset of all browsers. Browser scripting is fun enough in IE with its amusing conflation of Name and ID properties without getting into the weeds with a perfectly- safe-seeming data element being confused for some completely other property or method. Walter On Nov 21, 2010, at 2:15 PM, Luke wrote: Hi, is there anyting wrong with extending a DOM-Object with $('myelement').myvariable = something; or why is there the prototype-method store, which saves values in a seperate hash? Thank you, Lukas -- 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 athttp://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-scriptacul...@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: Extending a DOM-Object
Why is the Element::store() not listed in the documentation??? http://www.prototypejs.org/api/element . Thanks for pointing out this feature. I've been stupidly creating my own data structures to further describe DOM elements. Now I don't have to do that. On Nov 22, 12:31 pm, Luke kickingje...@gmail.com wrote: Thank you Mr Crowder, that was quite informative. Still I'm a little unsure how to proceed. If I got this right, it is common sense now that extending the DOM is the wrong thing to do. One of the main reasons is the possibility of name-conflicts. So I thought I might extend Objects with a JSON-Object (called 'builder' in my case) which contains all my methods and properties to (sort of) have my own namespace. But that would require a circular reference in my builder-object to the DOM-Element it is attached to (so the methods in my builder-object can work on the DOM they are attached to). I'm wondering if there's any way to keep that nice programming- paradigm prototype introduced with it's $-function, that you can simply write $('myelement').myfunction() while avoiding the above- mentioned problems. I could write my own wrapper-method, like jQuery's $-function, but that would miss the whole point of working with prototype. How do other people work with this? Luke On Nov 22, 7:37 am, T.J. Crowder t...@crowdersoftware.com wrote: Hi Luke, What you're talking about doing is called an expando property. They're not covered by a standard AFAIK, although interestingly Microsoft has an `expando` property on objects[1] (this is where the name came from) which is a boolean saying whether you can do this. If you do a web search on expando you'll find a lot more information (and a studio album by Timothy B. Schmit, but leave that aside...). (Ignore the statement on GreaseSpot that expandos relate to custom attributes; they don't, the article is just wrong.) Prototype uses expando properties like mad (the whole concept of extending an element[2] relies on expandos, and Prototype uses them elsewhere as well), so if you're using Prototype, you're already relying on the environment allowing expandos. But it's probably worth noting that Prototype is moving away from expandos at some point in favor of doing a jQuery-like wrapper thing instead. I'd avoid having your expando property value (directly or indirectly) reference another DOM element, as that sets up the possibility of circular references, and circular references that dip between the DOM and JavaScript layers can cause memory leaks on IE. [1]http://msdn.microsoft.com/en-us/library/ms533747(VS.85).aspx [2]http://prototypejs.org/learn/extensions Happy coding, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Nov 21, 8:28 pm, Luke kickingje...@gmail.com wrote: Thanks Walter. If that's the only reason I'm willing to take that risk. In my whole application I will only attach one variable, kind of like my namespace and this will give me some convenience when accessing that namespace. If it's conform to W3C standards and works in all browsers, I think it's ok. But is it? Can't find any documentation or specification on this Luke On Nov 21, 8:50 pm, Walter Lee Davis wa...@wdstudio.com wrote: I think that the basic reason for the separate store is to provide insulation from any current, past, or future browsers tramping on a key name you may choose today and test in some subset of all browsers. Browser scripting is fun enough in IE with its amusing conflation of Name and ID properties without getting into the weeds with a perfectly- safe-seeming data element being confused for some completely other property or method. Walter On Nov 21, 2010, at 2:15 PM, Luke wrote: Hi, is there anyting wrong with extending a DOM-Object with $('myelement').myvariable = something; or why is there the prototype-method store, which saves values in a seperate hash? Thank you, Lukas -- 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 athttp://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-scriptacul...@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] Firefox height:100% bug w/ prototype fix
I suggest that you insert a doctype and then run it through a validator until you get no errors or warning and then analyse what you are left with if you still have the problem. On 15 November 2010 19:26, Scott counterstre...@gmail.com wrote: So I've been working on a project the involves a table cell being scrollable. Firefox is not too friendly with height:100% when the parent element does not have a fixed height. (basically height:100% of height:auto = height:auto). From what I hear (and I don't want to start a standards compliance debate) firefox is following the rules but I'm not happy with it. IE, Chrome and Safari are rendering the desired results, I could care less who is doing it 'right'. This is more of a css issue but I'm pasting it here because I used the prototype library to aid me in my solution. http://pastie.org/1300351 let me know what you think or if you have any suggestions to improve my code. (please exclude your opinions on standards compliance) - Scott -- 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-scriptacul...@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-scriptacul...@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.