[Proto-Scripty] Re: Popup window
take a look at [http://prototype-window.xilinus.com/] prototype based window class that does confirm windows and others. .. On Mon, Nov 17, 2008 at 11:48 AM, Cristisor [EMAIL PROTECTED] wrote: Hi! I'm trying to build a popup window, something like the confirm box, but with more than Ok and Cancel. Can someone give me a start, I don't know how to make everything behind it read only so that the user can't click another link before he confirms his option? Thank you! --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Sending Json to the server
Morning Guys ... I am having a real headache trying to send json data to the server and have php decode it so i can do something with the data .. . Basically what i am trying to do is... I have a form and i would like to send data to the server in Json form (key/value pairs) so i can go over it in a loop with php cehcking somehting against a database... I did think of serialize() but i need to send information in a custom tag thats in some input values somethin like input type=text id=foo_12323142341234 class=formJson dbCol=forename value=John / input type=text id=foo_12323142344321 class=formJson dbCol=surname value=Doe / and have in the json var params=new Array(); $$('.formJson').each(function(e) { var p=$(e).dbCol + $(e).value; var d=p.toJSON(); params.push(d); } to end up with something like . forename : John, surname : Doe toJSON() seems to not be playing nice and tells me its not a function Can anyone think of a way to encode all the elements with the className of 'formJson' grabbing the custom tag (dbCol) and the value of the element into an object or an array and send it to the server (running php 5.2) so i can process it on the server end .. I've been scratching my head over it all morning and cant find a solution !! Regards 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: new AjaxRequest.....
you can assign the request to a variable myRequest = new Ajax.Request(.. - Original Message - From: Manish [EMAIL PROTECTED] To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Monday, November 17, 2008 9:09 AM Subject: [Proto-Scripty] new AjaxRequest. Whenever we do new AjaxRequest a new activeX object is created and sent to the url. Suppose you click multiple times, multiple request objects are sent to the url. If 5 requests sent 5 responses come back. My data on the page refreshes 5 times. Is there a way so that if I send multiple requests the browser returns only the responce corresponding to the last request sent. If I dont use prototype.js I can do this by declaring a variable request at a global scope and then assign the new activeX object to the same variable everytime it is required. so it does'nt matter how many requests i sent only the last one will remain as the reference variable was same. Please let me know how to handle the issue using prototype.js. Thanks --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Sending Json to the server
basically i think i need a push method to push values into a json object then i can try to decode it on the server!! - Original Message - From: Jeztah [EMAIL PROTECTED] To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Monday, November 17, 2008 11:51 AM Subject: [Proto-Scripty] Sending Json to the server Morning Guys ... I am having a real headache trying to send json data to the server and have php decode it so i can do something with the data .. . Basically what i am trying to do is... I have a form and i would like to send data to the server in Json form (key/value pairs) so i can go over it in a loop with php cehcking somehting against a database... I did think of serialize() but i need to send information in a custom tag thats in some input values somethin like input type=text id=foo_12323142341234 class=formJson dbCol=forename value=John / input type=text id=foo_12323142344321 class=formJson dbCol=surname value=Doe / and have in the json var params=new Array(); $$('.formJson').each(function(e) { var p=$(e).dbCol + $(e).value; var d=p.toJSON(); params.push(d); } to end up with something like . forename : John, surname : Doe toJSON() seems to not be playing nice and tells me its not a function Can anyone think of a way to encode all the elements with the className of 'formJson' grabbing the custom tag (dbCol) and the value of the element into an object or an array and send it to the server (running php 5.2) so i can process it on the server end .. I've been scratching my head over it all morning and cant find a solution !! Regards 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Sending Json to the server
cant use it as it needs to be custom as stipulated ... i need to get certain fields from the input elements .. merge() seems to want to do it but is not working as expected Thanks Alex - Original Message - From: Mona Remlawi [EMAIL PROTECTED] To: prototype-scriptaculous@googlegroups.com Sent: Monday, November 17, 2008 12:34 PM Subject: [Proto-Scripty] Re: Sending Json to the server hmm just out of the top of my head here, did you try using $H(form.serialiaze()) ? cheers -- mona [EMAIL PROTECTED] On Mon, Nov 17, 2008 at 1:13 PM, Alex Mcauley [EMAIL PROTECTED] wrote: basically i think i need a push method to push values into a json object then i can try to decode it on the server!! - Original Message - From: Jeztah [EMAIL PROTECTED] To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Monday, November 17, 2008 11:51 AM Subject: [Proto-Scripty] Sending Json to the server Morning Guys ... I am having a real headache trying to send json data to the server and have php decode it so i can do something with the data .. . Basically what i am trying to do is... I have a form and i would like to send data to the server in Json form (key/value pairs) so i can go over it in a loop with php cehcking somehting against a database... I did think of serialize() but i need to send information in a custom tag thats in some input values somethin like input type=text id=foo_12323142341234 class=formJson dbCol=forename value=John / input type=text id=foo_12323142344321 class=formJson dbCol=surname value=Doe / and have in the json var params=new Array(); $$('.formJson').each(function(e) { var p=$(e).dbCol + $(e).value; var d=p.toJSON(); params.push(d); } to end up with something like . forename : John, surname : Doe toJSON() seems to not be playing nice and tells me its not a function Can anyone think of a way to encode all the elements with the className of 'formJson' grabbing the custom tag (dbCol) and the value of the element into an object or an array and send it to the server (running php 5.2) so i can process it on the server end .. I've been scratching my head over it all morning and cant find a solution !! Regards 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Sending Json to the server
ok what about this: var params = {}; $$('.formJson').each(function(e) { params[$(e).dbCol] = $(e).value; } cheers -- mona [EMAIL PROTECTED] On Mon, Nov 17, 2008 at 1:43 PM, Alex Mcauley [EMAIL PROTECTED] wrote: cant use it as it needs to be custom as stipulated ... i need to get certain fields from the input elements .. merge() seems to want to do it but is not working as expected Thanks Alex - Original Message - From: Mona Remlawi [EMAIL PROTECTED] To: prototype-scriptaculous@googlegroups.com Sent: Monday, November 17, 2008 12:34 PM Subject: [Proto-Scripty] Re: Sending Json to the server hmm just out of the top of my head here, did you try using $H(form.serialiaze()) ? cheers -- mona [EMAIL PROTECTED] On Mon, Nov 17, 2008 at 1:13 PM, Alex Mcauley [EMAIL PROTECTED] wrote: basically i think i need a push method to push values into a json object then i can try to decode it on the server!! - Original Message - From: Jeztah [EMAIL PROTECTED] To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Monday, November 17, 2008 11:51 AM Subject: [Proto-Scripty] Sending Json to the server Morning Guys ... I am having a real headache trying to send json data to the server and have php decode it so i can do something with the data .. . Basically what i am trying to do is... I have a form and i would like to send data to the server in Json form (key/value pairs) so i can go over it in a loop with php cehcking somehting against a database... I did think of serialize() but i need to send information in a custom tag thats in some input values somethin like input type=text id=foo_12323142341234 class=formJson dbCol=forename value=John / input type=text id=foo_12323142344321 class=formJson dbCol=surname value=Doe / and have in the json var params=new Array(); $$('.formJson').each(function(e) { var p=$(e).dbCol + $(e).value; var d=p.toJSON(); params.push(d); } to end up with something like . forename : John, surname : Doe toJSON() seems to not be playing nice and tells me its not a function Can anyone think of a way to encode all the elements with the className of 'formJson' grabbing the custom tag (dbCol) and the value of the element into an object or an array and send it to the server (running php 5.2) so i can process it on the server end .. I've been scratching my head over it all morning and cant find a solution !! Regards 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Sending Json to the server
can i send all that into json afterwards to send it to the server ? Thanks Alex - Original Message - From: Mona Remlawi [EMAIL PROTECTED] To: prototype-scriptaculous@googlegroups.com Sent: Monday, November 17, 2008 12:52 PM Subject: [Proto-Scripty] Re: Sending Json to the server ok what about this: var params = {}; $$('.formJson').each(function(e) { params[$(e).dbCol] = $(e).value; } cheers -- mona [EMAIL PROTECTED] On Mon, Nov 17, 2008 at 1:43 PM, Alex Mcauley [EMAIL PROTECTED] wrote: cant use it as it needs to be custom as stipulated ... i need to get certain fields from the input elements .. merge() seems to want to do it but is not working as expected Thanks Alex - Original Message - From: Mona Remlawi [EMAIL PROTECTED] To: prototype-scriptaculous@googlegroups.com Sent: Monday, November 17, 2008 12:34 PM Subject: [Proto-Scripty] Re: Sending Json to the server hmm just out of the top of my head here, did you try using $H(form.serialiaze()) ? cheers -- mona [EMAIL PROTECTED] On Mon, Nov 17, 2008 at 1:13 PM, Alex Mcauley [EMAIL PROTECTED] wrote: basically i think i need a push method to push values into a json object then i can try to decode it on the server!! - Original Message - From: Jeztah [EMAIL PROTECTED] To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Monday, November 17, 2008 11:51 AM Subject: [Proto-Scripty] Sending Json to the server Morning Guys ... I am having a real headache trying to send json data to the server and have php decode it so i can do something with the data .. . Basically what i am trying to do is... I have a form and i would like to send data to the server in Json form (key/value pairs) so i can go over it in a loop with php cehcking somehting against a database... I did think of serialize() but i need to send information in a custom tag thats in some input values somethin like input type=text id=foo_12323142341234 class=formJson dbCol=forename value=John / input type=text id=foo_12323142344321 class=formJson dbCol=surname value=Doe / and have in the json var params=new Array(); $$('.formJson').each(function(e) { var p=$(e).dbCol + $(e).value; var d=p.toJSON(); params.push(d); } to end up with something like . forename : John, surname : Doe toJSON() seems to not be playing nice and tells me its not a function Can anyone think of a way to encode all the elements with the className of 'formJson' grabbing the custom tag (dbCol) and the value of the element into an object or an array and send it to the server (running php 5.2) so i can process it on the server end .. I've been scratching my head over it all morning and cant find a solution !! Regards 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Sending Json to the server
here's what i will do to send the json to server --- new Ajax.Request(url, { postBody: Object.toJSON(params), contentType: text/javascript, onSuccess: function(xhr) { }, onFailure: function(xhr) { }, onComplete: function(xhr) { } }); --- another thing, you can lose those redundant $(e) in the array iterator. cheers -- mona [EMAIL PROTECTED] On Mon, Nov 17, 2008 at 1:53 PM, Alex Mcauley [EMAIL PROTECTED] wrote: can i send all that into json afterwards to send it to the server ? Thanks Alex - Original Message - From: Mona Remlawi [EMAIL PROTECTED] To: prototype-scriptaculous@googlegroups.com Sent: Monday, November 17, 2008 12:52 PM Subject: [Proto-Scripty] Re: Sending Json to the server ok what about this: var params = {}; $$('.formJson').each(function(e) { params[$(e).dbCol] = $(e).value; } cheers -- mona [EMAIL PROTECTED] On Mon, Nov 17, 2008 at 1:43 PM, Alex Mcauley [EMAIL PROTECTED] wrote: cant use it as it needs to be custom as stipulated ... i need to get certain fields from the input elements .. merge() seems to want to do it but is not working as expected Thanks Alex - Original Message - From: Mona Remlawi [EMAIL PROTECTED] To: prototype-scriptaculous@googlegroups.com Sent: Monday, November 17, 2008 12:34 PM Subject: [Proto-Scripty] Re: Sending Json to the server hmm just out of the top of my head here, did you try using $H(form.serialiaze()) ? cheers -- mona [EMAIL PROTECTED] On Mon, Nov 17, 2008 at 1:13 PM, Alex Mcauley [EMAIL PROTECTED] wrote: basically i think i need a push method to push values into a json object then i can try to decode it on the server!! - Original Message - From: Jeztah [EMAIL PROTECTED] To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Monday, November 17, 2008 11:51 AM Subject: [Proto-Scripty] Sending Json to the server Morning Guys ... I am having a real headache trying to send json data to the server and have php decode it so i can do something with the data .. . Basically what i am trying to do is... I have a form and i would like to send data to the server in Json form (key/value pairs) so i can go over it in a loop with php cehcking somehting against a database... I did think of serialize() but i need to send information in a custom tag thats in some input values somethin like input type=text id=foo_12323142341234 class=formJson dbCol=forename value=John / input type=text id=foo_12323142344321 class=formJson dbCol=surname value=Doe / and have in the json var params=new Array(); $$('.formJson').each(function(e) { var p=$(e).dbCol + $(e).value; var d=p.toJSON(); params.push(d); } to end up with something like . forename : John, surname : Doe toJSON() seems to not be playing nice and tells me its not a function Can anyone think of a way to encode all the elements with the className of 'formJson' grabbing the custom tag (dbCol) and the value of the element into an object or an array and send it to the server (running php 5.2) so i can process it on the server end .. I've been scratching my head over it all morning and cant find a solution !! Regards 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Sending Json to the server
I suppose what i need is a push into my json object method ... though i cant seem to find a working one in prototypejs .. merge(); and update(); both seem to want to be used with $H() but it updates with my var ... Something like {l : doe} when it should be {surname : doe}; plus it doesnt merge each of them !! it only merges the last one !! Regards Alex - Original Message - From: T.J. Crowder [EMAIL PROTECTED] To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Monday, November 17, 2008 1:05 PM Subject: [Proto-Scripty] Re: Sending Json to the server Alex, Why send it to the server in JSON format as opposed to standard POST encoding? If all you want is key/value pairs, just sending POST data seems much more straight-forward. Separately, on the code: $$('.formJson').each(function(e) { var p=$(e).dbCol + $(e).value; var d=p.toJSON(); params.push(d);} $$ returns extended elements[1], so no need to extend them again (much less repeatedly). Also, when creating 'p', you're not putting any kind of delimiter between the dbCol property and the value, so you'll get a string like surnameDoe. Also, you're expecting to be able to access an attribute of an element ('dbCol') as thought it were a property of the Element object; you can't. You can get it via Prototype's readAttribute method[2], though. [1] http://www.prototypejs.org/api/utility/dollar-dollar [2] http://www.prototypejs.org/api/element/readAttribute -- T.J. Crowder tj / crowder software / com On Nov 17, 11:51 am, Jeztah [EMAIL PROTECTED] wrote: Morning Guys ... I am having a real headache trying to send json data to the server and have php decode it so i can do something with the data .. . Basically what i am trying to do is... I have a form and i would like to send data to the server in Json form (key/value pairs) so i can go over it in a loop with php cehcking somehting against a database... I did think of serialize() but i need to send information in a custom tag thats in some input values somethin like input type=text id=foo_12323142341234 class=formJson dbCol=forename value=John / input type=text id=foo_12323142344321 class=formJson dbCol=surname value=Doe / and have in the json var params=new Array(); $$('.formJson').each(function(e) { var p=$(e).dbCol + $(e).value; var d=p.toJSON(); params.push(d);} to end up with something like . forename : John, surname : Doe toJSON() seems to not be playing nice and tells me its not a function Can anyone think of a way to encode all the elements with the className of 'formJson' grabbing the custom tag (dbCol) and the value of the element into an object or an array and send it to the server (running php 5.2) so i can process it on the server end .. I've been scratching my head over it all morning and cant find a solution !! Regards 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajax.Responders
Hi, What Alex posted wasn't a bug -- or at least, wasn't a bug in Prototype. What's this other bug you're speaking of? Can you post an example? -- T.J. Crowder tj / crowder software / com On Nov 17, 9:07 am, bluezehn [EMAIL PROTECTED] wrote: Incidentally, I believe there is a similar bug if you use the onSuccess/onFailure callbacks - if you do, then the Ajax.Responder's onSuccess/onFailure's don't fire On Nov 15, 9:40 am, T.J. Crowder [EMAIL PROTECTED] wrote: Alex, You're incrementing and decrementing Ajax.activeRequestCount, which is already being maintained by Prototype. Look again at the docs[1], it tells you that it's doing that. Hence your getting odd results. If you want to just use Ajax.activeRequestCount, you can do that; or if you want to duplicate its functionality, you can do that by using your own count variable, but you don't want to be modifying the one that's also being modified by Prototype. -- T.J. Crowder tj / crowder software / com On Nov 14, 1:04 pm, Alex Mcauley [EMAIL PROTECTED] wrote: sorry my original code was wrong .. http://pastie.org/314784 The code above actually says 2 requests when there should only be 1 !!! Here is a better example i cant recreate the problem entirely as it needs a few periodical updaters to be going on in the background but when they are and code like this is run then the request count goes up and up and up when there is no request going on!! Regards Alex - Original Message - From: T.J. Crowder [EMAIL PROTECTED] To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Friday, November 14, 2008 12:02 PM Subject: [Proto-Scripty] Re: Ajax.Responders Hi, When creating an Ajax.Updater for instance if you use the method onComplete in the Ajax.Options then it never unloads the Request from the Ajax.Responders counter Can you put together a small, self-contained test page demonstrating the issue, post it to Pastie[1], and link to it from here? If another set of eyes says it's a bug rather than (apologies) a misunderstanding, we'll want to raise a ticket for it on Lighthouse. [1] http:/pastie.org Thanks, -- T.J. Crowder tj / crowder software / com On Nov 14, 11:12 am, Jeztah [EMAIL PROTECTED] wrote: Just to let everyone know i may have found a little bug in the Ajax.Responders .. or maybe it is mean to to this way When creating an Ajax.Updater for instance if you use the method onComplete in the Ajax.Options then it never unloads the Request from the Ajax.Responders counter If you dont use onComplete in your options then it does ... Strange behaviour it seems as i was wondering why something was keeping my Request count high on a page when it should be unloaded and removed from the pool If its not a bug someone may have been scratching thier head for an hour like me trying to figure it out .. In my case i was creating an activity display to show me when Ajax calls were being made on a page Regards 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Can't call a function within a class using each or invoke
great readings suggested. when you finish, you can try the following :) $$('.editable').each(function(e) {e.observe('click', (function() {this._editField(e)}).bind(this))}, this); the problem is that when you iterate, you have to specify the context. On Mon, Nov 17, 2008 at 2:15 PM, T.J. Crowder [EMAIL PROTECTED] wrote: Hi George, Go back to school! ;-) No, seriously, you don't need to wrap the call to bindAsEventListener () in a function; that's its job. You also don't have to pass the event object to it. (And you probably want bind()[1] rather than bindAsEventListener().) [1] http://prototypejs.org/api/function/bind Some resources that will probably help, both with the concept... http://blog.niftysnippets.org/2008/04/you-must-remember-this.html http://www.alistapart.com/articles/getoutbindingsituations ...and the details: http://proto-scripty.wikidot.com/prototype:how-to-hooking-events (the example near the end alks about instance methods, but I recommend reading through from the beginning). HTH, -- T.J. Crowder tj / crowder software / com On Nov 17, 1:00 pm, George [EMAIL PROTECTED] wrote: Hi Folks, I'm pretty sure that I'm going to be told to go back to school here, but I've wasted a whole morning trying to figure this out - now it's time to ask the experts. I've simplified my code here to demonstrate what I'm trying to do: [CODE] var buildPage = {}; buildPage = Class.create(); buildPage.prototype = { initialize: function() { this.rowTemplate = 'tr...' this.rs = []; this._getData(); },// initialize _getData : function() {//using AJAX to grab a JSON array from the server and store it in this.rs}, _parseTemplate : function() {//write data to screen then add event listeners $$('.editable').invoke('observe', 'mouseover',function(e){e.element ().addClassName('pseudo-text-box')}); $$('.editable').invoke('observe', 'mouseout',function(e){e.element ().removeClassName('pseudo-text-box')}); $$('.editable').invoke('observe', 'click', function(e) {this._editField.bindAsEventListener(this, e) }); }, _editField : function(e) { //Inject INPUT field} }; [/CODE] My problem is with this line: $$('.editable').invoke('observe', 'click', function(e) {this._editField.bindAsEventListener(this, e) }); At runtime, I always get the message that this._editField is not a function, no matter how I try the binding. The only way I can get this to work is to initiate the class (var a = new buildPage) than call c._editField from within the function - but that's not much good when I come to re-use it. Can someone explain to me what's going on here - I'm stumped. Many thanks George --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Javascript error in IE6 for Effect.Highlight
Hi, I just started with Scriptaculous. I tried using Effect Highlight property in the below piece of code. !-- li id=menu1 onmouseover=new Effect.Highlight(this, { startcolor: '#99', endcolor: '#ff', restorecolor: 'true' }); return false; Menu1/li -- I tested it with IE6 and Firefox 3. It is working fine in both except that i am getting an javascript error in IE6 status bar. This error states 'Invalid Property value' at line 1909, char 9. I get this only when i use restorecolor property. I have linked prototype.js and scriptaculous.js to my html file. I think the error is generated in prototype.js. Since this file spans more than 1909 lines of code. Please help me out with this. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Javascript error in IE6 for Effect.Highlight
true / flase should usually be not in quotes ... try removing the quotes - Original Message - From: scripter [EMAIL PROTECTED] To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Monday, November 17, 2008 1:35 PM Subject: [Proto-Scripty] Javascript error in IE6 for Effect.Highlight Hi, I just started with Scriptaculous. I tried using Effect Highlight property in the below piece of code. !-- li id=menu1 onmouseover=new Effect.Highlight(this, { startcolor: '#99', endcolor: '#ff', restorecolor: 'true' }); return false; Menu1/li -- I tested it with IE6 and Firefox 3. It is working fine in both except that i am getting an javascript error in IE6 status bar. This error states 'Invalid Property value' at line 1909, char 9. I get this only when i use restorecolor property. I have linked prototype.js and scriptaculous.js to my html file. I think the error is generated in prototype.js. Since this file spans more than 1909 lines of code. Please help me out with this. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Sending Json to the server
Also the code you quote me on was psuedo code just to try to give an idea of what i am trying to achieve - i know it was unworking ! Alex, you've said that several times now. If you post code that's not code, please say it's not code to avoid wasting people's time. Looking at: var p=$(e).dbCol + $(e).value; ...it's not at all clear that's not meant to be code. Not *good* code, but I've seen worse. ;-) Thanks, -- T.J. On Nov 17, 1:11 pm, Alex Mcauley [EMAIL PROTECTED] wrote: because i need to evaluate each one and i need to send other post data that does not need evaluating .. the other post data is not allways static so i cant put if/else clauses on my serverside code to accomidate it ... what i need is the data from the each loop send as 1 post parameter and my other data sent as other parameters.. I've been looking at toJSON() on the array created with the method supplied to me earlier .. Also the code you quote me on was psuedo code just to try to give an idea of what i am trying to achieve - i know it was unworking ! Thanks Alex - Original Message - From: T.J. Crowder [EMAIL PROTECTED] To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Monday, November 17, 2008 1:05 PM Subject: [Proto-Scripty] Re: Sending Json to the server Alex, Why send it to the server in JSON format as opposed to standard POST encoding? If all you want is key/value pairs, just sending POST data seems much more straight-forward. Separately, on the code: $$('.formJson').each(function(e) { var p=$(e).dbCol + $(e).value; var d=p.toJSON(); params.push(d);} $$ returns extended elements[1], so no need to extend them again (much less repeatedly). Also, when creating 'p', you're not putting any kind of delimiter between the dbCol property and the value, so you'll get a string like surnameDoe. Also, you're expecting to be able to access an attribute of an element ('dbCol') as thought it were a property of the Element object; you can't. You can get it via Prototype's readAttribute method[2], though. [1]http://www.prototypejs.org/api/utility/dollar-dollar [2]http://www.prototypejs.org/api/element/readAttribute -- T.J. Crowder tj / crowder software / com On Nov 17, 11:51 am, Jeztah [EMAIL PROTECTED] wrote: Morning Guys ... I am having a real headache trying to send json data to the server and have php decode it so i can do something with the data .. . Basically what i am trying to do is... I have a form and i would like to send data to the server in Json form (key/value pairs) so i can go over it in a loop with php cehcking somehting against a database... I did think of serialize() but i need to send information in a custom tag thats in some input values somethin like input type=text id=foo_12323142341234 class=formJson dbCol=forename value=John / input type=text id=foo_12323142344321 class=formJson dbCol=surname value=Doe / and have in the json var params=new Array(); $$('.formJson').each(function(e) { var p=$(e).dbCol + $(e).value; var d=p.toJSON(); params.push(d);} to end up with something like . forename : John, surname : Doe toJSON() seems to not be playing nice and tells me its not a function Can anyone think of a way to encode all the elements with the className of 'formJson' grabbing the custom tag (dbCol) and the value of the element into an object or an array and send it to the server (running php 5.2) so i can process it on the server end .. I've been scratching my head over it all morning and cant find a solution !! Regards 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Sending Json to the server
okay m8 calm down lol its no biggie .. - Original Message - From: T.J. Crowder [EMAIL PROTECTED] To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Monday, November 17, 2008 2:01 PM Subject: [Proto-Scripty] Re: Sending Json to the server Also the code you quote me on was psuedo code just to try to give an idea of what i am trying to achieve - i know it was unworking ! Alex, you've said that several times now. If you post code that's not code, please say it's not code to avoid wasting people's time. Looking at: var p=$(e).dbCol + $(e).value; ...it's not at all clear that's not meant to be code. Not *good* code, but I've seen worse. ;-) Thanks, -- T.J. On Nov 17, 1:11 pm, Alex Mcauley [EMAIL PROTECTED] wrote: because i need to evaluate each one and i need to send other post data that does not need evaluating .. the other post data is not allways static so i cant put if/else clauses on my serverside code to accomidate it ... what i need is the data from the each loop send as 1 post parameter and my other data sent as other parameters.. I've been looking at toJSON() on the array created with the method supplied to me earlier .. Also the code you quote me on was psuedo code just to try to give an idea of what i am trying to achieve - i know it was unworking ! Thanks Alex - Original Message - From: T.J. Crowder [EMAIL PROTECTED] To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Monday, November 17, 2008 1:05 PM Subject: [Proto-Scripty] Re: Sending Json to the server Alex, Why send it to the server in JSON format as opposed to standard POST encoding? If all you want is key/value pairs, just sending POST data seems much more straight-forward. Separately, on the code: $$('.formJson').each(function(e) { var p=$(e).dbCol + $(e).value; var d=p.toJSON(); params.push(d);} $$ returns extended elements[1], so no need to extend them again (much less repeatedly). Also, when creating 'p', you're not putting any kind of delimiter between the dbCol property and the value, so you'll get a string like surnameDoe. Also, you're expecting to be able to access an attribute of an element ('dbCol') as thought it were a property of the Element object; you can't. You can get it via Prototype's readAttribute method[2], though. [1]http://www.prototypejs.org/api/utility/dollar-dollar [2]http://www.prototypejs.org/api/element/readAttribute -- T.J. Crowder tj / crowder software / com On Nov 17, 11:51 am, Jeztah [EMAIL PROTECTED] wrote: Morning Guys ... I am having a real headache trying to send json data to the server and have php decode it so i can do something with the data .. . Basically what i am trying to do is... I have a form and i would like to send data to the server in Json form (key/value pairs) so i can go over it in a loop with php cehcking somehting against a database... I did think of serialize() but i need to send information in a custom tag thats in some input values somethin like input type=text id=foo_12323142341234 class=formJson dbCol=forename value=John / input type=text id=foo_12323142344321 class=formJson dbCol=surname value=Doe / and have in the json var params=new Array(); $$('.formJson').each(function(e) { var p=$(e).dbCol + $(e).value; var d=p.toJSON(); params.push(d);} to end up with something like . forename : John, surname : Doe toJSON() seems to not be playing nice and tells me its not a function Can anyone think of a way to encode all the elements with the className of 'formJson' grabbing the custom tag (dbCol) and the value of the element into an object or an array and send it to the server (running php 5.2) so i can process it on the server end .. I've been scratching my head over it all morning and cant find a solution !! Regards 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Sending Json to the server
Guys, please stay courteous (and that includes avoiding shorthand). Thank you! Tobie On Nov 17, 3:33 pm, Alex Mcauley [EMAIL PROTECTED] wrote: okay m8 calm down lol its no biggie .. - Original Message - From: T.J. Crowder [EMAIL PROTECTED] To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Monday, November 17, 2008 2:01 PM Subject: [Proto-Scripty] Re: Sending Json to the server Also the code you quote me on was psuedo code just to try to give an idea of what i am trying to achieve - i know it was unworking ! Alex, you've said that several times now. If you post code that's not code, please say it's not code to avoid wasting people's time. Looking at: var p=$(e).dbCol + $(e).value; ...it's not at all clear that's not meant to be code. Not *good* code, but I've seen worse. ;-) Thanks, -- T.J. On Nov 17, 1:11 pm, Alex Mcauley [EMAIL PROTECTED] wrote: because i need to evaluate each one and i need to send other post data that does not need evaluating .. the other post data is not allways static so i cant put if/else clauses on my serverside code to accomidate it ... what i need is the data from the each loop send as 1 post parameter and my other data sent as other parameters.. I've been looking at toJSON() on the array created with the method supplied to me earlier .. Also the code you quote me on was psuedo code just to try to give an idea of what i am trying to achieve - i know it was unworking ! Thanks Alex - Original Message - From: T.J. Crowder [EMAIL PROTECTED] To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Monday, November 17, 2008 1:05 PM Subject: [Proto-Scripty] Re: Sending Json to the server Alex, Why send it to the server in JSON format as opposed to standard POST encoding? If all you want is key/value pairs, just sending POST data seems much more straight-forward. Separately, on the code: $$('.formJson').each(function(e) { var p=$(e).dbCol + $(e).value; var d=p.toJSON(); params.push(d);} $$ returns extended elements[1], so no need to extend them again (much less repeatedly). Also, when creating 'p', you're not putting any kind of delimiter between the dbCol property and the value, so you'll get a string like surnameDoe. Also, you're expecting to be able to access an attribute of an element ('dbCol') as thought it were a property of the Element object; you can't. You can get it via Prototype's readAttribute method[2], though. [1]http://www.prototypejs.org/api/utility/dollar-dollar [2]http://www.prototypejs.org/api/element/readAttribute -- T.J. Crowder tj / crowder software / com On Nov 17, 11:51 am, Jeztah [EMAIL PROTECTED] wrote: Morning Guys ... I am having a real headache trying to send json data to the server and have php decode it so i can do something with the data .. . Basically what i am trying to do is... I have a form and i would like to send data to the server in Json form (key/value pairs) so i can go over it in a loop with php cehcking somehting against a database... I did think of serialize() but i need to send information in a custom tag thats in some input values somethin like input type=text id=foo_12323142341234 class=formJson dbCol=forename value=John / input type=text id=foo_12323142344321 class=formJson dbCol=surname value=Doe / and have in the json var params=new Array(); $$('.formJson').each(function(e) { var p=$(e).dbCol + $(e).value; var d=p.toJSON(); params.push(d);} to end up with something like . forename : John, surname : Doe toJSON() seems to not be playing nice and tells me its not a function Can anyone think of a way to encode all the elements with the className of 'formJson' grabbing the custom tag (dbCol) and the value of the element into an object or an array and send it to the server (running php 5.2) so i can process it on the server end .. I've been scratching my head over it all morning and cant find a solution !! Regards 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Sending Json to the server
No problems here. - Original Message - From: Tobie Langel [EMAIL PROTECTED] To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Monday, November 17, 2008 2:48 PM Subject: [Proto-Scripty] Re: Sending Json to the server Guys, please stay courteous (and that includes avoiding shorthand). Thank you! Tobie On Nov 17, 3:33 pm, Alex Mcauley [EMAIL PROTECTED] wrote: okay m8 calm down lol its no biggie .. - Original Message - From: T.J. Crowder [EMAIL PROTECTED] To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Monday, November 17, 2008 2:01 PM Subject: [Proto-Scripty] Re: Sending Json to the server Also the code you quote me on was psuedo code just to try to give an idea of what i am trying to achieve - i know it was unworking ! Alex, you've said that several times now. If you post code that's not code, please say it's not code to avoid wasting people's time. Looking at: var p=$(e).dbCol + $(e).value; ...it's not at all clear that's not meant to be code. Not *good* code, but I've seen worse. ;-) Thanks, -- T.J. On Nov 17, 1:11 pm, Alex Mcauley [EMAIL PROTECTED] wrote: because i need to evaluate each one and i need to send other post data that does not need evaluating .. the other post data is not allways static so i cant put if/else clauses on my serverside code to accomidate it ... what i need is the data from the each loop send as 1 post parameter and my other data sent as other parameters.. I've been looking at toJSON() on the array created with the method supplied to me earlier .. Also the code you quote me on was psuedo code just to try to give an idea of what i am trying to achieve - i know it was unworking ! Thanks Alex - Original Message - From: T.J. Crowder [EMAIL PROTECTED] To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Monday, November 17, 2008 1:05 PM Subject: [Proto-Scripty] Re: Sending Json to the server Alex, Why send it to the server in JSON format as opposed to standard POST encoding? If all you want is key/value pairs, just sending POST data seems much more straight-forward. Separately, on the code: $$('.formJson').each(function(e) { var p=$(e).dbCol + $(e).value; var d=p.toJSON(); params.push(d);} $$ returns extended elements[1], so no need to extend them again (much less repeatedly). Also, when creating 'p', you're not putting any kind of delimiter between the dbCol property and the value, so you'll get a string like surnameDoe. Also, you're expecting to be able to access an attribute of an element ('dbCol') as thought it were a property of the Element object; you can't. You can get it via Prototype's readAttribute method[2], though. [1]http://www.prototypejs.org/api/utility/dollar-dollar [2]http://www.prototypejs.org/api/element/readAttribute -- T.J. Crowder tj / crowder software / com On Nov 17, 11:51 am, Jeztah [EMAIL PROTECTED] wrote: Morning Guys ... I am having a real headache trying to send json data to the server and have php decode it so i can do something with the data .. . Basically what i am trying to do is... I have a form and i would like to send data to the server in Json form (key/value pairs) so i can go over it in a loop with php cehcking somehting against a database... I did think of serialize() but i need to send information in a custom tag thats in some input values somethin like input type=text id=foo_12323142341234 class=formJson dbCol=forename value=John / input type=text id=foo_12323142344321 class=formJson dbCol=surname value=Doe / and have in the json var params=new Array(); $$('.formJson').each(function(e) { var p=$(e).dbCol + $(e).value; var d=p.toJSON(); params.push(d);} to end up with something like . forename : John, surname : Doe toJSON() seems to not be playing nice and tells me its not a function Can anyone think of a way to encode all the elements with the className of 'formJson' grabbing the custom tag (dbCol) and the value of the element into an object or an array and send it to the server (running php 5.2) so i can process it on the server end .. I've been scratching my head over it all morning and cant find a solution !! Regards 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Can't call a function within a class using each or invoke
T.J. - Mona, Thank you both very much for your solutions, recommended reading lists and T.J, for your event delegation suggestion. FYI Mona's solution worked out of the box but T.J. your event delegation suggestion makes a lot of sense - I suspect I will add a new method to my class to handle all clicks. I'm going to do some reading first though - will start with ALA's article on binding. Many thanks George On Nov 17, 1:54 pm, T.J. Crowder [EMAIL PROTECTED] wrote: Doh! I missed he was doing all of this in an invoke, what I get for skimming. Wow, that's convoluted. Good answer, though. George, AFAICS Mona's solution will work for your _editField function as defined. But FWIW, I'd probably define a separate function intended as an event handler. (The reason Mona's had to create an anonymous function to bind is that she needs to ditch the event object parameter _editField isn't expecting to see.) Doing that would simplify things a bit, I think, and make it easier for debugging. Another thing you might consider is event delegation: Hook the 'click' event on whatever the container of these 'editable's is, and use one event handler rather than many. Clicks on descendent elements bubble up to the parent container, and you can get the element on which the click actually happened from the event object. So given this, for instance: div id='container' span class='editable'foo foo foo/span span class='editable'bar bar barspan /div You can just hook 'click' on the 'container' rather than the editables: $('container').observe('click', this.handleContainerClick.bind(this)); and your handler might look like this: function handleContainerClick(event) { var elm; // Get the element on which the click actually occurred elm = event.findElement(); // Does it exist, and is it editable? if (elm elm.hasClassName('editable')) { // Yes, edit it this._editField(elm); } } Various links on event delegation can be found here:http://proto-scripty.wikidot.com/faq#delegation HTH, -- T.J. Crowder tj / crowder software / com On Nov 17, 1:34 pm, Mona Remlawi [EMAIL PROTECTED] wrote: great readings suggested. when you finish, you can try the following :) $$('.editable').each(function(e) {e.observe('click', (function() {this._editField(e)}).bind(this))}, this); the problem is that when you iterate, you have to specify the context. On Mon, Nov 17, 2008 at 2:15 PM, T.J. Crowder [EMAIL PROTECTED] wrote: Hi George, Go back to school! ;-) No, seriously, you don't need to wrap the call to bindAsEventListener () in a function; that's its job. You also don't have to pass the event object to it. (And you probably want bind()[1] rather than bindAsEventListener().) [1]http://prototypejs.org/api/function/bind Some resources that will probably help, both with the concept... http://blog.niftysnippets.org/2008/04/you-must-remember-this.html http://www.alistapart.com/articles/getoutbindingsituations ...and the details: http://proto-scripty.wikidot.com/prototype:how-to-hooking-events (the example near the end alks about instance methods, but I recommend reading through from the beginning). HTH, -- T.J. Crowder tj / crowder software / com On Nov 17, 1:00 pm, George [EMAIL PROTECTED] wrote: Hi Folks, I'm pretty sure that I'm going to be told to go back to school here, but I've wasted a whole morning trying to figure this out - now it's time to ask the experts. I've simplified my code here to demonstrate what I'm trying to do: [CODE] var buildPage = {}; buildPage = Class.create(); buildPage.prototype = { initialize: function() { this.rowTemplate = 'tr...' this.rs = []; this._getData(); },// initialize _getData : function() {//using AJAX to grab a JSON array from the server and store it in this.rs}, _parseTemplate : function() {//write data to screen then add event listeners $$('.editable').invoke('observe', 'mouseover',function(e){e.element ().addClassName('pseudo-text-box')}); $$('.editable').invoke('observe', 'mouseout',function(e){e.element ().removeClassName('pseudo-text-box')}); $$('.editable').invoke('observe', 'click', function(e) {this._editField.bindAsEventListener(this, e) }); }, _editField : function(e) { //Inject INPUT field} }; [/CODE] My problem is with this line: $$('.editable').invoke('observe', 'click', function(e) {this._editField.bindAsEventListener(this, e) }); At runtime, I always get the message that this._editField is not a function, no matter how I try the binding. The only way I can get this to work is to initiate the class (var a = new buildPage) than call c._editField from within the function - but that's not much good when I come to re-use it. Can someone explain to me what's going on here -
[Proto-Scripty] Re: Can't call a function within a class using each or invoke
Good call George, I'll do the same :) cheers -- mona [EMAIL PROTECTED] On Mon, Nov 17, 2008 at 4:13 PM, George [EMAIL PROTECTED] wrote: T.J. - Mona, Thank you both very much for your solutions, recommended reading lists and T.J, for your event delegation suggestion. FYI Mona's solution worked out of the box but T.J. your event delegation suggestion makes a lot of sense - I suspect I will add a new method to my class to handle all clicks. I'm going to do some reading first though - will start with ALA's article on binding. Many thanks George On Nov 17, 1:54 pm, T.J. Crowder [EMAIL PROTECTED] wrote: Doh! I missed he was doing all of this in an invoke, what I get for skimming. Wow, that's convoluted. Good answer, though. George, AFAICS Mona's solution will work for your _editField function as defined. But FWIW, I'd probably define a separate function intended as an event handler. (The reason Mona's had to create an anonymous function to bind is that she needs to ditch the event object parameter _editField isn't expecting to see.) Doing that would simplify things a bit, I think, and make it easier for debugging. Another thing you might consider is event delegation: Hook the 'click' event on whatever the container of these 'editable's is, and use one event handler rather than many. Clicks on descendent elements bubble up to the parent container, and you can get the element on which the click actually happened from the event object. So given this, for instance: div id='container' span class='editable'foo foo foo/span span class='editable'bar bar barspan /div You can just hook 'click' on the 'container' rather than the editables: $('container').observe('click', this.handleContainerClick.bind(this)); and your handler might look like this: function handleContainerClick(event) { var elm; // Get the element on which the click actually occurred elm = event.findElement(); // Does it exist, and is it editable? if (elm elm.hasClassName('editable')) { // Yes, edit it this._editField(elm); } } Various links on event delegation can be found here:http://proto-scripty.wikidot.com/faq#delegation HTH, -- T.J. Crowder tj / crowder software / com On Nov 17, 1:34 pm, Mona Remlawi [EMAIL PROTECTED] wrote: great readings suggested. when you finish, you can try the following :) $$('.editable').each(function(e) {e.observe('click', (function() {this._editField(e)}).bind(this))}, this); the problem is that when you iterate, you have to specify the context. On Mon, Nov 17, 2008 at 2:15 PM, T.J. Crowder [EMAIL PROTECTED] wrote: Hi George, Go back to school! ;-) No, seriously, you don't need to wrap the call to bindAsEventListener () in a function; that's its job. You also don't have to pass the event object to it. (And you probably want bind()[1] rather than bindAsEventListener().) [1]http://prototypejs.org/api/function/bind Some resources that will probably help, both with the concept... http://blog.niftysnippets.org/2008/04/you-must-remember-this.html http://www.alistapart.com/articles/getoutbindingsituations ...and the details: http://proto-scripty.wikidot.com/prototype:how-to-hooking-events (the example near the end alks about instance methods, but I recommend reading through from the beginning). HTH, -- T.J. Crowder tj / crowder software / com On Nov 17, 1:00 pm, George [EMAIL PROTECTED] wrote: Hi Folks, I'm pretty sure that I'm going to be told to go back to school here, but I've wasted a whole morning trying to figure this out - now it's time to ask the experts. I've simplified my code here to demonstrate what I'm trying to do: [CODE] var buildPage = {}; buildPage = Class.create(); buildPage.prototype = { initialize: function() { this.rowTemplate = 'tr...' this.rs = []; this._getData(); },// initialize _getData : function() {//using AJAX to grab a JSON array from the server and store it in this.rs}, _parseTemplate : function() {//write data to screen then add event listeners $$('.editable').invoke('observe', 'mouseover',function(e){e.element ().addClassName('pseudo-text-box')}); $$('.editable').invoke('observe', 'mouseout',function(e){e.element ().removeClassName('pseudo-text-box')}); $$('.editable').invoke('observe', 'click', function(e) {this._editField.bindAsEventListener(this, e) }); }, _editField : function(e) { //Inject INPUT field} }; [/CODE] My problem is with this line: $$('.editable').invoke('observe', 'click', function(e) {this._editField.bindAsEventListener(this, e) }); At runtime, I always get the message that this._editField is not a function, no matter how I try the binding. The only way I can get this to work is to initiate the class (var a = new buildPage) than
[Proto-Scripty] Re: private methods/variables declaration
On Nov 17, 4:13 am, Mona Remlawi [EMAIL PROTECTED] wrote: [...] I'm wondering if this is a good practice. Are there any insights that i should be aware of? Are the private methods/functions being duplicated for each of myclass instance? If what you need is to create private static (class) members, then yes, this is one of the most straight-forward ways to do so. Private functions are not being duplicated; they are declared only once. When an instance is created, public instance methods are still shared via prototype chain, but also have an access to private functions (as they were declared in the same scope). Thanks in advance -- mona [EMAIL PROTECTED] -- kangax --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: private methods/variables declaration
Super, I like the word shared. I'll keep an eye not to have any state in the private block :-) cheers -- mona [EMAIL PROTECTED] On Mon, Nov 17, 2008 at 4:23 PM, kangax [EMAIL PROTECTED] wrote: On Nov 17, 4:13 am, Mona Remlawi [EMAIL PROTECTED] wrote: [...] I'm wondering if this is a good practice. Are there any insights that i should be aware of? Are the private methods/functions being duplicated for each of myclass instance? If what you need is to create private static (class) members, then yes, this is one of the most straight-forward ways to do so. Private functions are not being duplicated; they are declared only once. When an instance is created, public instance methods are still shared via prototype chain, but also have an access to private functions (as they were declared in the same scope). Thanks in advance -- mona [EMAIL PROTECTED] -- kangax --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: private methods/variables declaration
on teh same ish subject, this cropped up on ajaxian today !!... might be worth a read http://ajaxian.com/archives/trying-to-be-private-in-javascript - Original Message - From: Mona Remlawi [EMAIL PROTECTED] To: prototype-scriptaculous@googlegroups.com Sent: Monday, November 17, 2008 3:43 PM Subject: [Proto-Scripty] Re: private methods/variables declaration Super, I like the word shared. I'll keep an eye not to have any state in the private block :-) cheers -- mona [EMAIL PROTECTED] On Mon, Nov 17, 2008 at 4:23 PM, kangax [EMAIL PROTECTED] wrote: On Nov 17, 4:13 am, Mona Remlawi [EMAIL PROTECTED] wrote: [...] I'm wondering if this is a good practice. Are there any insights that i should be aware of? Are the private methods/functions being duplicated for each of myclass instance? If what you need is to create private static (class) members, then yes, this is one of the most straight-forward ways to do so. Private functions are not being duplicated; they are declared only once. When an instance is created, public instance methods are still shared via prototype chain, but also have an access to private functions (as they were declared in the same scope). Thanks in advance -- mona [EMAIL PROTECTED] -- kangax --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] simple problem
Hello: I've been trying to use Ajax.Request(). The following is my code: function retrieveProjectPermissions(stateDataID, projectID) { new Ajax.Request('/gallupFaith/me25/ ProjectPermissionsAjaxAction.action', { method:'get', parameters: {statedataid: stateDataID, projectid: projectID}, onSuccess: function(transport){ var responsePP = transport.responseText; alert(Success! \n\n + responsePP); if (agentPP.indexOf('msie') != -1) { var permissionArray = msPopulatePP(responsePP); return permissionsArray; } else if (agentPP.indexOf('mozilla') != -1) { var permissionArray = nonMSPopulatePP(responsePP); return permissionsArray; } }, onFailure: function(){ alert('Something went wrong...') } }); } I am trying to return the variable permissionsArray to the caller of retrieveProjectPermissions(). I can't use global variables because there is some timing issue . . . the variables always end up undefined after I set them. How can I return permissionsArray? Thanks Eric- --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: simple problem
On Nov 17, 12:13 pm, badgerduke [EMAIL PROTECTED] wrote: Hello: I've been trying to use Ajax.Request(). The following is my code: function retrieveProjectPermissions(stateDataID, projectID) { new Ajax.Request('/gallupFaith/me25/ ProjectPermissionsAjaxAction.action', { method:'get', parameters: {statedataid: stateDataID, projectid: projectID}, onSuccess: function(transport){ var responsePP = transport.responseText; alert(Success! \n\n + responsePP); if (agentPP.indexOf('msie') != -1) { Is this based on UA sniffing? If yes, then it's not a good idea. How do `msPopulatePP` and its counterpart differ? var permissionArray = msPopulatePP(responsePP); return permissionsArray; } else if (agentPP.indexOf('mozilla') != -1) { Same here : ) var permissionArray = nonMSPopulatePP(responsePP); return permissionsArray; } }, onFailure: function(){ alert('Something went wrong...') } }); } I am trying to return the variable permissionsArray to the caller of retrieveProjectPermissions(). I can't use global variables because there is some timing issue . . . the variables always end up undefined after I set them. How can I return permissionsArray? Ajax.Request is asynchronous. `onSuccess` is called much later after `retrieveProjectPermissions` exits (when client receives response from the server and that response is successful). Use `onSuccess` to retrieve and then start using that variable; E.g. you can pass some kind of callback to enclosing function and invoke that callback function passing it variable in question: function retrieveProjectPermissions(stateDataID, projectID, callback) { // ... // initialize Ajax.Request // ... onSuccess: function(response) { // get permissionArray callback(permissionArray); } }; and then call it like so: retrieveProjectPermissions(1, 23, function(arr) { // do something with `arr` }); Thanks Eric- -- kangax --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Event.observe doesn't work on window scroll event
On Nov 17, 12:16 pm, Joe Moore [EMAIL PROTECTED] wrote: I'm trying to use the bind to the windows.onscroll event with Event.observe, but it doesn't work. No error is reported. Here is a small bit of JavaScript I am using: function initPage() { Event.observe(window, scroll, function() { alert(Hello World); }); `window` needs to be an actual reference, not a string representing id of an element : ) Hence, Event.observe(window, 'scroll', function() { alert('Hello, World!'); }) [...] -- kangax --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Updater from within an iframe
I've seen postings similar to my problem, but they didn't answer my question. Within an iframe, I've defined a div id='target/div Within the same iframe, I have some javascript: script function ajaxrefresh() { window.document.getElementById('target').innerHTML='...Loading'; new parent.Ajax.Updater('target', './refresh.php5, { method: 'get'}); } /script The getElementById() finds the target div OK. But Ajax.Updater doesn't. Since prototype is loaded by the parent window, and I don't want to load the whole thing again just for a little iframe, I have to go to the parent window, but Ajax can't find its way back. I tried setting a var to the location: var target=window.document.getElementById('target'); Then saying Ajax.Updater(target, ...) But Updater wants a string for the first argument. Bottom line: how do you make Updater find something inside an iframe? Thanks in advance, Ron --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Intellisense for prototype with Visual Studio 2008??
Hello, Is there any signs of having intellisense for prototype in Visual Studio??...the same way it works for Jquery?? Is there any prototype.vsdoc.js file available?? Thanks --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] new with question about dom:loaded on ie
Hi, I'm just new to the group - it is proper to ask support questions here? I'm having trouble with dom:loaded on IE6, any ideas where to look? Everything is fine on Firefox. Another area of trouble seems to be on Safari (Windows) getting at selectors like $$ ('table#tblTMRoster'). Again, any ideas for best ways to trace what is happening - I sure miss Firebug everywhere else. Thanks, --Jay --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---