[Proto-Scripty] Re: Class with Ajax and onclick event
On Aug 4, 2:24 pm, Liviu Timar mailti...@gmail.com wrote: var Dynamic = Class.create({ initialize: function(selector, container, script) { this.selector = selector; this.script = script; this.container = container; this.changeContent = this.changeContent.bindAsEventListener(this); this.getContent(); }, getContent: function() { new Ajax.Request(this.script, { onSuccess: function(req) { this.content = req.responseJSON; This is ths problem. Inside the function definition, there is a new scope, and 'this' will not have been assigned (because callbacks don't get called as methods). Either you need to #bind your onSuccess function, or I would just use another variable: getContent: function() { var that = this; onSuccess: function(req) { that.content = req.responseJSON; ... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Class with Ajax and onclick event
Thank you for the response. You're right, I declared another variable and now it works fine. I have two other problems, though: I can't pass an aditional argument to the event handler(changeContent) and I can't figure out how can I make the content change automatic... On Aug 5, 11:33 am, ColinFine colin.f...@pace.com wrote: On Aug 4, 2:24 pm, Liviu Timar mailti...@gmail.com wrote: var Dynamic = Class.create({ initialize: function(selector, container, script) { this.selector = selector; this.script = script; this.container = container; this.changeContent = this.changeContent.bindAsEventListener(this); this.getContent(); }, getContent: function() { new Ajax.Request(this.script, { onSuccess: function(req) { this.content = req.responseJSON; This is ths problem. Inside the function definition, there is a new scope, and 'this' will not have been assigned (because callbacks don't get called as methods). Either you need to #bind your onSuccess function, or I would just use another variable: getContent: function() { var that = this; onSuccess: function(req) { that.content = req.responseJSON; ... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Using a prototype function in dynamic content.
$(div).update(thereturn); That did the trick! It's true that I don't make as much use of prototype as I could or should. Most of the js/ajax on the site is written from scratch (way back when I was learning how to use ajax). I added prototype later on to do some of the 'bells and whistles' stuff. I will certainly take the time to read the api as I'm sure there are all sorts of things it could help with on the site. Many thanks, Chris --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Ajax.Responders issues
Hi, I am trying to setup some basic Ajax framework, and I was thinking to use Ajax.Responders to intercept some events, but I meet the following issues : - First, it seems that the responders ignore an onSuccess() callback passed through Ajax.Responders.register(). This may be a documentation error since the Prototype 1.6 - The Complete API Reference says that All callbacks in the life-cycle are available on the Ajax.Responders.register() description (p32) but the list of Responder callbacks (p25) only lists 7 of them (not including onSuccess). My second concern is that Responder's callback seems to be always called after the local one (the one defined in the ajax call). I wanted to implement some kind of server throwable exceptions, which basically would allow me to return a JSON object with some attributes like {Error:true, Code:ExpiredSession...} which would be handled by the default Responder, freeing me from having to test all unexpected things in every Ajax's callback. The current behavior doesn't allow to do that easily. I do think to a solution but don't you think that for the sake of clarity those Responder callback should be renamed from onXXX to onAfterXXX since they are called after the actual onXXX callback ? (and eventually, some onBeforeXXX callback could be added (as well as onSuccess and onFailure). I am not very happy with the workaround I found, so feel free to give me some hints to make it better. Here it is: function ResponderOnSuccess(localOnSuccess,request,jsonObj) { if(!jsonObj) jsonObj = { Error: true, Code:Unknown}; if(jsonObj.Error) { // process error; } else { localOnSuccess(request,jsonObj); } } and for using it: new Ajax.Request('myRequest.php', { onSuccess: myCB.wrap(ResponderOnSuccess) }); or if you prefer: new Ajax.Request('myRequest.php', { onSuccess: (function(xrh,json) { // Process data here }).wrap(ResponderOnSuccess) }); Last minute idea I just had while writing: Do you think I could use the onCreate's responder to change the onSuccess by the wrapped version? Thanks for any hint, 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 prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Class with Ajax and onclick event
Depending on when you wanted to pass the additional argument you could just attach it to the argument chain on bind this.changeContent = this.changeContent.bindAsEventListener(this, extraArgument); Since we're already looking at that line of code, be careful, reassigning the function to a bound version of itself could get tricky if you decide to create a subclass of Dynamic. -- http://positionabsolute.net On Aug 4, 9:24 am, Liviu Timar mailti...@gmail.com wrote: Hello, This is my first post here. Thus, I'll like to say hello to everybody in this community and I want to appologize if this question was asked before. I am a web developer for a site that has 1mil+ visitors/month: www [dot] ziare [dot] ro, and I want to use the Prototype Framework to make an element refresh itself (with an scriptaculous Effect) periodically. This is my class: var Dynamic = Class.create({ initialize: function(selector, container, script) { this.selector = selector; this.script = script; this.container = container; this.changeContent = this.changeContent.bindAsEventListener(this); this.getContent(); }, getContent: function() { new Ajax.Request(this.script, { onSuccess: function(req) { this.content = req.responseJSON; //document.fire('content:retrieved', req.responseJSON); } }); $$(this.selector).invoke('observe', 'click', this.changeContent.bind (this)); }, changeContent: function(event) { event.preventDefault(); console.log(this.content); console.log(this.container); /*new Effect.Fade($(this.container), { afterFinish: function() { new Effect.Appear($(this.container)); } }); $(this.container).update('cucu');*/ }}); document.observe('dom:loaded', function() { var dyn = new Dynamic(.tzNavLink a, tzContent, titlurileZilei.php); }); 'tzContent' is the div whose content changes by clicking on of the links with the 'tzNavLink' css class (the 1 2 3 4 5 6 links onwww.ziare.ro). The problem is that this.content is undefined in changeContent (a function that listens for the click event), although this.container works well in the same function. Why is that? It has something to do with the Ajax.Request? Also, I want to ask how can I 'tzContent' to change periodically using such and object (I want everything to be encapsulated so I can use this object in other projects)? Thank you for your response. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Beginners question, trouble with Event.stop in AJAX
Try adding e.preventDefault(); instead of Event.stop(e) and let me know if that works? On Tue, Aug 4, 2009 at 4:55 PM, Ashashley.kenner...@gmail.com wrote: function callProcBasketEmail(e) { var pars = Form.serialize('email-form'); var myAjax = new Ajax.Updater('email-response', 'procBasketEmail.php', { method: 'post', parameters: pars, onSuccess: function(response) { Event.observe('password-form', 'submit', callProcBasketPassword); } }); Event.stop(e); } --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Beginners question, trouble with Event.stop in AJAX
Hi, I wasn't sure whether you meant in the 1st or second function, but it doesn't make a difference in either. I think it is the Event.observe('password-form', 'submit', callProcBasketPassword); which is not working properly, although I don't know how to debug it On Aug 5, 6:48 pm, DJ Mangus d.man...@gmail.com wrote: Try adding e.preventDefault(); instead of Event.stop(e) and let me know if that works? On Tue, Aug 4, 2009 at 4:55 PM, Ashashley.kenner...@gmail.com wrote: function callProcBasketEmail(e) { var pars = Form.serialize('email-form'); var myAjax = new Ajax.Updater('email-response', 'procBasketEmail.php', { method: 'post', parameters: pars, onSuccess: function(response) { Event.observe('password-form', 'submit', callProcBasketPassword); } }); Event.stop(e); } --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Browser scroller position after Ajax.Update
Hello. My problem when is apparent on my page. The div to be updated (and link) are a long way down the page so users have to scroll down. When they press the link and thus update the div the browsers scroller returns to top, forcing the user to scroll down again to the div. Is there any quickfix (like option I have missed) or more advanced solution? Best Regards and Thanks in Advance, Joel --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Browser scroller position after Ajax.Update
Can you explain it a bit better please... i cant really understand what you mean by that Thanks Alex Mcauley http://www.thevacancymarket.com - Original Message - From: DJJQ joll...@hotmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Wednesday, August 05, 2009 8:22 PM Subject: [Proto-Scripty] Browser scroller position after Ajax.Update Hello. My problem when is apparent on my page. The div to be updated (and link) are a long way down the page so users have to scroll down. When they press the link and thus update the div the browsers scroller returns to top, forcing the user to scroll down again to the div. Is there any quickfix (like option I have missed) or more advanced solution? Best Regards and Thanks in Advance, Joel --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Browser scroller position after Ajax.Update
Oh my god my english was terrible in my post, sorry about that. I'll try to explain the problem again: On my php page I have a link a long way down the page, so users have to scroll down a bit. the link triggers an ajax.update on the page. When users press the link the browser returns to the top of the page. How do I restore the browser position to where the link is? (So the scroller position remains unchanged when calling ajax update) On Aug 5, 9:45 pm, Alex McAuley webmas...@thecarmarketplace.com wrote: Can you explain it a bit better please... i cant really understand what you mean by that Thanks Alex Mcauleyhttp://www.thevacancymarket.com - Original Message - From: DJJQ joll...@hotmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Wednesday, August 05, 2009 8:22 PM Subject: [Proto-Scripty] Browser scroller position after Ajax.Update Hello. My problem when is apparent on my page. The div to be updated (and link) are a long way down the page so users have to scroll down. When they press the link and thus update the div the browsers scroller returns to top, forcing the user to scroll down again to the div. Is there any quickfix (like option I have missed) or more advanced solution? Best Regards and Thanks in Advance, Joel --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Browser scroller position after Ajax.Update
Maybe this might help. http://www.prototypejs.org/api/element/scrollto On Wed, Aug 5, 2009 at 1:33 PM, DJJQjoll...@hotmail.com wrote: Oh my god my english was terrible in my post, sorry about that. I'll try to explain the problem again: On my php page I have a link a long way down the page, so users have to scroll down a bit. the link triggers an ajax.update on the page. When users press the link the browser returns to the top of the page. How do I restore the browser position to where the link is? (So the scroller position remains unchanged when calling ajax update) On Aug 5, 9:45 pm, Alex McAuley webmas...@thecarmarketplace.com wrote: Can you explain it a bit better please... i cant really understand what you mean by that Thanks Alex Mcauleyhttp://www.thevacancymarket.com - Original Message - From: DJJQ joll...@hotmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Wednesday, August 05, 2009 8:22 PM Subject: [Proto-Scripty] Browser scroller position after Ajax.Update Hello. My problem when is apparent on my page. The div to be updated (and link) are a long way down the page so users have to scroll down. When they press the link and thus update the div the browsers scroller returns to top, forcing the user to scroll down again to the div. Is there any quickfix (like option I have missed) or more advanced solution? Best Regards and Thanks in Advance, Joel --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Beginners question, trouble with Event.stop in AJAX
Are you getting any Javascript errors? Note: firefox and firebug is your friend. Don't forget to break on all errors. On Wed, Aug 5, 2009 at 11:22 AM, Ashashley.kenner...@gmail.com wrote: Hi, I wasn't sure whether you meant in the 1st or second function, but it doesn't make a difference in either. I think it is the Event.observe('password-form', 'submit', callProcBasketPassword); which is not working properly, although I don't know how to debug it On Aug 5, 6:48 pm, DJ Mangus d.man...@gmail.com wrote: Try adding e.preventDefault(); instead of Event.stop(e) and let me know if that works? On Tue, Aug 4, 2009 at 4:55 PM, Ashashley.kenner...@gmail.com wrote: function callProcBasketEmail(e) { var pars = Form.serialize('email-form'); var myAjax = new Ajax.Updater('email-response', 'procBasketEmail.php', { method: 'post', parameters: pars, onSuccess: function(response) { Event.observe('password-form', 'submit', callProcBasketPassword); } }); Event.stop(e); } --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Browser scroller position after Ajax.Update
what does the link look like ? a href=# Click me/a Like that ? Alex Mcauley http://www.thevacancymarket.com - Original Message - From: DJJQ joll...@hotmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Wednesday, August 05, 2009 9:33 PM Subject: [Proto-Scripty] Re: Browser scroller position after Ajax.Update Oh my god my english was terrible in my post, sorry about that. I'll try to explain the problem again: On my php page I have a link a long way down the page, so users have to scroll down a bit. the link triggers an ajax.update on the page. When users press the link the browser returns to the top of the page. How do I restore the browser position to where the link is? (So the scroller position remains unchanged when calling ajax update) On Aug 5, 9:45 pm, Alex McAuley webmas...@thecarmarketplace.com wrote: Can you explain it a bit better please... i cant really understand what you mean by that Thanks Alex Mcauleyhttp://www.thevacancymarket.com - Original Message - From: DJJQ joll...@hotmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Wednesday, August 05, 2009 8:22 PM Subject: [Proto-Scripty] Browser scroller position after Ajax.Update Hello. My problem when is apparent on my page. The div to be updated (and link) are a long way down the page so users have to scroll down. When they press the link and thus update the div the browsers scroller returns to top, forcing the user to scroll down again to the div. Is there any quickfix (like option I have missed) or more advanced solution? Best Regards and Thanks in Advance, Joel --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Browser scroller position after Ajax.Update
Yes that's right. Maybe that's the problem, should I javascript:null it? On Aug 5, 10:40 pm, Alex McAuley webmas...@thecarmarketplace.com wrote: what does the link look like ? a href=# Click me/a Like that ? Alex Mcauleyhttp://www.thevacancymarket.com - Original Message - From: DJJQ joll...@hotmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Wednesday, August 05, 2009 9:33 PM Subject: [Proto-Scripty] Re: Browser scroller position after Ajax.Update Oh my god my english was terrible in my post, sorry about that. I'll try to explain the problem again: On my php page I have a link a long way down the page, so users have to scroll down a bit. the link triggers an ajax.update on the page. When users press the link the browser returns to the top of the page. How do I restore the browser position to where the link is? (So the scroller position remains unchanged when calling ajax update) On Aug 5, 9:45 pm, Alex McAuley webmas...@thecarmarketplace.com wrote: Can you explain it a bit better please... i cant really understand what you mean by that Thanks Alex Mcauleyhttp://www.thevacancymarket.com - Original Message - From: DJJQ joll...@hotmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Wednesday, August 05, 2009 8:22 PM Subject: [Proto-Scripty] Browser scroller position after Ajax.Update Hello. My problem when is apparent on my page. The div to be updated (and link) are a long way down the page so users have to scroll down. When they press the link and thus update the div the browsers scroller returns to top, forcing the user to scroll down again to the div. Is there any quickfix (like option I have missed) or more advanced solution? Best Regards and Thanks in Advance, Joel --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Class with Ajax and onclick event
Sorry, I forgot to specify. This is the code: getContent: function() { var dyn = this; new Ajax.Request(this.script, { onSuccess: function(req) { dyn.content = req.responseJSON; document.fire('content:retrieved', req.responseJSON); } }); //$$(this.selector).invoke('observe', 'click', this.changeContent.bind(this)); $$(this.selector).each(function(element, index) { element.observe('click', dyn.changeContent.bind(dyn)); }); } I want to pass the index as an extra argument to dyn.changeContent, because I want to know which of the links was clicked. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Browser scroller position after Ajax.Update
Nope... If you are observing the click with observe() just call Event.stop(event); on it Example. $('myHref').observe('click',function(event) { Event.stop(event); Your ajax code here. }); That way it will degrade in browsers not having javascript and they will just goto the href of the link. HTH Alex Mcauley http://www.thevacancymarket.com - Original Message - From: DJJQ joll...@hotmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Wednesday, August 05, 2009 9:42 PM Subject: [Proto-Scripty] Re: Browser scroller position after Ajax.Update Yes that's right. Maybe that's the problem, should I javascript:null it? On Aug 5, 10:40 pm, Alex McAuley webmas...@thecarmarketplace.com wrote: what does the link look like ? a href=# Click me/a Like that ? Alex Mcauleyhttp://www.thevacancymarket.com - Original Message - From: DJJQ joll...@hotmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Wednesday, August 05, 2009 9:33 PM Subject: [Proto-Scripty] Re: Browser scroller position after Ajax.Update Oh my god my english was terrible in my post, sorry about that. I'll try to explain the problem again: On my php page I have a link a long way down the page, so users have to scroll down a bit. the link triggers an ajax.update on the page. When users press the link the browser returns to the top of the page. How do I restore the browser position to where the link is? (So the scroller position remains unchanged when calling ajax update) On Aug 5, 9:45 pm, Alex McAuley webmas...@thecarmarketplace.com wrote: Can you explain it a bit better please... i cant really understand what you mean by that Thanks Alex Mcauleyhttp://www.thevacancymarket.com - Original Message - From: DJJQ joll...@hotmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Wednesday, August 05, 2009 8:22 PM Subject: [Proto-Scripty] Browser scroller position after Ajax.Update Hello. My problem when is apparent on my page. The div to be updated (and link) are a long way down the page so users have to scroll down. When they press the link and thus update the div the browsers scroller returns to top, forcing the user to scroll down again to the div. Is there any quickfix (like option I have missed) or more advanced solution? Best Regards and Thanks in Advance, Joel --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Beginners question, trouble with Event.stop in AJAX
When I set firebug to break on all errors... Submit the first form and I get (from prototype.js) function getEventID(element) { element is null3936 if (element._prototypeEventID) return element._prototypeEventID[0]; (element is null error) if I step past it and submit the second form I get the same error again Unfortunately I don't know why both errors are caused, can you help please? On Aug 5, 9:40 pm, DJ Mangus d.man...@gmail.com wrote: Are you getting any Javascript errors? Note: firefox and firebug is your friend. Don't forget to break on all errors. On Wed, Aug 5, 2009 at 11:22 AM, Ashashley.kenner...@gmail.com wrote: Hi, I wasn't sure whether you meant in the 1st or second function, but it doesn't make a difference in either. I think it is the Event.observe('password-form', 'submit', callProcBasketPassword); which is not working properly, although I don't know how to debug it On Aug 5, 6:48 pm, DJ Mangus d.man...@gmail.com wrote: Try adding e.preventDefault(); instead of Event.stop(e) and let me know if that works? On Tue, Aug 4, 2009 at 4:55 PM, Ashashley.kenner...@gmail.com wrote: function callProcBasketEmail(e) { var pars = Form.serialize('email-form'); var myAjax = new Ajax.Updater('email-response', 'procBasketEmail.php', { method: 'post', parameters: pars, onSuccess: function(response) { Event.observe('password-form', 'submit', callProcBasketPassword); } }); Event.stop(e); } --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Beginners question, trouble with Event.stop in AJAX
Seems the element does not exist... Does it exist in the DOM ? Alex Mcauley http://www.thevacancymarket.com - Original Message - From: Ash ashley.kenner...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Wednesday, August 05, 2009 10:04 PM Subject: [Proto-Scripty] Re: Beginners question, trouble with Event.stop in AJAX When I set firebug to break on all errors... Submit the first form and I get (from prototype.js) function getEventID(element) { element is null3936 if (element._prototypeEventID) return element._prototypeEventID[0]; (element is null error) if I step past it and submit the second form I get the same error again Unfortunately I don't know why both errors are caused, can you help please? On Aug 5, 9:40 pm, DJ Mangus d.man...@gmail.com wrote: Are you getting any Javascript errors? Note: firefox and firebug is your friend. Don't forget to break on all errors. On Wed, Aug 5, 2009 at 11:22 AM, Ashashley.kenner...@gmail.com wrote: Hi, I wasn't sure whether you meant in the 1st or second function, but it doesn't make a difference in either. I think it is the Event.observe('password-form', 'submit', callProcBasketPassword); which is not working properly, although I don't know how to debug it On Aug 5, 6:48 pm, DJ Mangus d.man...@gmail.com wrote: Try adding e.preventDefault(); instead of Event.stop(e) and let me know if that works? On Tue, Aug 4, 2009 at 4:55 PM, Ashashley.kenner...@gmail.com wrote: function callProcBasketEmail(e) { var pars = Form.serialize('email-form'); var myAjax = new Ajax.Updater('email-response', 'procBasketEmail.php', { method: 'post', parameters: pars, onSuccess: function(response) { Event.observe('password-form', 'submit', callProcBasketPassword); } }); Event.stop(e); } --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Beginners question, trouble with Event.stop in AJAX
nods when Firebug breaks on the error, check the DOM tab to see the state at that particular moment. On Wed, Aug 5, 2009 at 2:05 PM, Alex McAuleywebmas...@thecarmarketplace.com wrote: Seems the element does not exist... Does it exist in the DOM ? Alex Mcauley http://www.thevacancymarket.com - Original Message - From: Ash ashley.kenner...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Wednesday, August 05, 2009 10:04 PM Subject: [Proto-Scripty] Re: Beginners question, trouble with Event.stop in AJAX When I set firebug to break on all errors... Submit the first form and I get (from prototype.js) function getEventID(element) { element is null3936 if (element._prototypeEventID) return element._prototypeEventID[0]; (element is null error) if I step past it and submit the second form I get the same error again Unfortunately I don't know why both errors are caused, can you help please? On Aug 5, 9:40 pm, DJ Mangus d.man...@gmail.com wrote: Are you getting any Javascript errors? Note: firefox and firebug is your friend. Don't forget to break on all errors. On Wed, Aug 5, 2009 at 11:22 AM, Ashashley.kenner...@gmail.com wrote: Hi, I wasn't sure whether you meant in the 1st or second function, but it doesn't make a difference in either. I think it is the Event.observe('password-form', 'submit', callProcBasketPassword); which is not working properly, although I don't know how to debug it On Aug 5, 6:48 pm, DJ Mangus d.man...@gmail.com wrote: Try adding e.preventDefault(); instead of Event.stop(e) and let me know if that works? On Tue, Aug 4, 2009 at 4:55 PM, Ashashley.kenner...@gmail.com wrote: function callProcBasketEmail(e) { var pars = Form.serialize('email-form'); var myAjax = new Ajax.Updater('email-response', 'procBasketEmail.php', { method: 'post', parameters: pars, onSuccess: function(response) { Event.observe('password-form', 'submit', callProcBasketPassword); } }); Event.stop(e); } --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Beginners question, trouble with Event.stop in AJAX
Sorry, i'm quite new to this, should I be looking for the form id=password-form element in the DOM, not sure where to look for it in the DOM tab of firebug? Is this correct? On Aug 5, 10:06 pm, DJ Mangus d.man...@gmail.com wrote: nods when Firebug breaks on the error, check the DOM tab to see the state at that particular moment. On Wed, Aug 5, 2009 at 2:05 PM, Alex McAuleywebmas...@thecarmarketplace.com wrote: Seems the element does not exist... Does it exist in the DOM ? Alex Mcauley http://www.thevacancymarket.com - Original Message - From: Ash ashley.kenner...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Wednesday, August 05, 2009 10:04 PM Subject: [Proto-Scripty] Re: Beginners question, trouble with Event.stop in AJAX When I set firebug to break on all errors... Submit the first form and I get (from prototype.js) function getEventID(element) { element is null3936 if (element._prototypeEventID) return element._prototypeEventID[0]; (element is null error) if I step past it and submit the second form I get the same error again Unfortunately I don't know why both errors are caused, can you help please? On Aug 5, 9:40 pm, DJ Mangus d.man...@gmail.com wrote: Are you getting any Javascript errors? Note: firefox and firebug is your friend. Don't forget to break on all errors. On Wed, Aug 5, 2009 at 11:22 AM, Ashashley.kenner...@gmail.com wrote: Hi, I wasn't sure whether you meant in the 1st or second function, but it doesn't make a difference in either. I think it is the Event.observe('password-form', 'submit', callProcBasketPassword); which is not working properly, although I don't know how to debug it On Aug 5, 6:48 pm, DJ Mangus d.man...@gmail.com wrote: Try adding e.preventDefault(); instead of Event.stop(e) and let me know if that works? On Tue, Aug 4, 2009 at 4:55 PM, Ashashley.kenner...@gmail.com wrote: function callProcBasketEmail(e) { var pars = Form.serialize('email-form'); var myAjax = new Ajax.Updater('email-response', 'procBasketEmail.php', { method: 'post', parameters: pars, onSuccess: function(response) { Event.observe('password-form', 'submit', callProcBasketPassword); } }); Event.stop(e); } --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Beginners question, trouble with Event.stop in AJAX
actually just checked firebug, best place would be html tab. DOM tab lists the entire DOM which would be very hard to go through. On Wed, Aug 5, 2009 at 2:12 PM, Ashashley.kenner...@gmail.com wrote: Sorry, i'm quite new to this, should I be looking for the form id=password-form element in the DOM, not sure where to look for it in the DOM tab of firebug? Is this correct? On Aug 5, 10:06 pm, DJ Mangus d.man...@gmail.com wrote: nods when Firebug breaks on the error, check the DOM tab to see the state at that particular moment. On Wed, Aug 5, 2009 at 2:05 PM, Alex McAuleywebmas...@thecarmarketplace.com wrote: Seems the element does not exist... Does it exist in the DOM ? Alex Mcauley http://www.thevacancymarket.com - Original Message - From: Ash ashley.kenner...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Wednesday, August 05, 2009 10:04 PM Subject: [Proto-Scripty] Re: Beginners question, trouble with Event.stop in AJAX When I set firebug to break on all errors... Submit the first form and I get (from prototype.js) function getEventID(element) { element is null3936 if (element._prototypeEventID) return element._prototypeEventID[0]; (element is null error) if I step past it and submit the second form I get the same error again Unfortunately I don't know why both errors are caused, can you help please? On Aug 5, 9:40 pm, DJ Mangus d.man...@gmail.com wrote: Are you getting any Javascript errors? Note: firefox and firebug is your friend. Don't forget to break on all errors. On Wed, Aug 5, 2009 at 11:22 AM, Ashashley.kenner...@gmail.com wrote: Hi, I wasn't sure whether you meant in the 1st or second function, but it doesn't make a difference in either. I think it is the Event.observe('password-form', 'submit', callProcBasketPassword); which is not working properly, although I don't know how to debug it On Aug 5, 6:48 pm, DJ Mangus d.man...@gmail.com wrote: Try adding e.preventDefault(); instead of Event.stop(e) and let me know if that works? On Tue, Aug 4, 2009 at 4:55 PM, Ashashley.kenner...@gmail.com wrote: function callProcBasketEmail(e) { var pars = Form.serialize('email-form'); var myAjax = new Ajax.Updater('email-response', 'procBasketEmail.php', { method: 'post', parameters: pars, onSuccess: function(response) { Event.observe('password-form', 'submit', callProcBasketPassword); } }); Event.stop(e); } --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Beginners question, trouble with Event.stop in AJAX
yes, when I check the HTML tab, the form with the id=password-form has not been created within the email-response div, even though I have waited to check for it with the onSuccess line EG function callProcBasketEmail(e) { var pars = Form.serialize('email-form'); var myAjax = new Ajax.Updater('email-response', 'procBasketEmail.php', { method: 'post', parameters: pars, onSuccess: function(response) { Event.observe('password-form', 'submit', callProcBasketPassword); } }); Event.stop(e); } Once I jump past the error, the email-response div gets populated with the form i'm trying to observe, so the question is, why is the onSuccess running before the DOM has been updated? On Aug 5, 10:17 pm, DJ Mangus d.man...@gmail.com wrote: actually just checked firebug, best place would be html tab. DOM tab lists the entire DOM which would be very hard to go through. On Wed, Aug 5, 2009 at 2:12 PM, Ashashley.kenner...@gmail.com wrote: Sorry, i'm quite new to this, should I be looking for the form id=password-form element in the DOM, not sure where to look for it in the DOM tab of firebug? Is this correct? On Aug 5, 10:06 pm, DJ Mangus d.man...@gmail.com wrote: nods when Firebug breaks on the error, check the DOM tab to see the state at that particular moment. On Wed, Aug 5, 2009 at 2:05 PM, Alex McAuleywebmas...@thecarmarketplace.com wrote: Seems the element does not exist... Does it exist in the DOM ? Alex Mcauley http://www.thevacancymarket.com - Original Message - From: Ash ashley.kenner...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Wednesday, August 05, 2009 10:04 PM Subject: [Proto-Scripty] Re: Beginners question, trouble with Event.stop in AJAX When I set firebug to break on all errors... Submit the first form and I get (from prototype.js) function getEventID(element) { element is null3936 if (element._prototypeEventID) return element._prototypeEventID[0]; (element is null error) if I step past it and submit the second form I get the same error again Unfortunately I don't know why both errors are caused, can you help please? On Aug 5, 9:40 pm, DJ Mangus d.man...@gmail.com wrote: Are you getting any Javascript errors? Note: firefox and firebug is your friend. Don't forget to break on all errors. On Wed, Aug 5, 2009 at 11:22 AM, Ashashley.kenner...@gmail.com wrote: Hi, I wasn't sure whether you meant in the 1st or second function, but it doesn't make a difference in either. I think it is the Event.observe('password-form', 'submit', callProcBasketPassword); which is not working properly, although I don't know how to debug it On Aug 5, 6:48 pm, DJ Mangus d.man...@gmail.com wrote: Try adding e.preventDefault(); instead of Event.stop(e) and let me know if that works? On Tue, Aug 4, 2009 at 4:55 PM, Ashashley.kenner...@gmail.com wrote: function callProcBasketEmail(e) { var pars = Form.serialize('email-form'); var myAjax = new Ajax.Updater('email-response', 'procBasketEmail.php', { method: 'post', parameters: pars, onSuccess: function(response) { Event.observe('password-form', 'submit', callProcBasketPassword); } }); Event.stop(e); } --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Beginners question, trouble with Event.stop in AJAX
good question. You might change Event.observe( . . . etc to Event.observe.defer( . . . and see if that fixes it. Odd that the node isn't available in the DOM at onSuccess but that might work around it while I research. On Wed, Aug 5, 2009 at 2:22 PM, Ashashley.kenner...@gmail.com wrote: yes, when I check the HTML tab, the form with the id=password-form has not been created within the email-response div, even though I have waited to check for it with the onSuccess line EG function callProcBasketEmail(e) { var pars = Form.serialize('email-form'); var myAjax = new Ajax.Updater('email-response', 'procBasketEmail.php', { method: 'post', parameters: pars, onSuccess: function(response) { Event.observe('password-form', 'submit', callProcBasketPassword); } }); Event.stop(e); } Once I jump past the error, the email-response div gets populated with the form i'm trying to observe, so the question is, why is the onSuccess running before the DOM has been updated? On Aug 5, 10:17 pm, DJ Mangus d.man...@gmail.com wrote: actually just checked firebug, best place would be html tab. DOM tab lists the entire DOM which would be very hard to go through. On Wed, Aug 5, 2009 at 2:12 PM, Ashashley.kenner...@gmail.com wrote: Sorry, i'm quite new to this, should I be looking for the form id=password-form element in the DOM, not sure where to look for it in the DOM tab of firebug? Is this correct? On Aug 5, 10:06 pm, DJ Mangus d.man...@gmail.com wrote: nods when Firebug breaks on the error, check the DOM tab to see the state at that particular moment. On Wed, Aug 5, 2009 at 2:05 PM, Alex McAuleywebmas...@thecarmarketplace.com wrote: Seems the element does not exist... Does it exist in the DOM ? Alex Mcauley http://www.thevacancymarket.com - Original Message - From: Ash ashley.kenner...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Wednesday, August 05, 2009 10:04 PM Subject: [Proto-Scripty] Re: Beginners question, trouble with Event.stop in AJAX When I set firebug to break on all errors... Submit the first form and I get (from prototype.js) function getEventID(element) { element is null3936 if (element._prototypeEventID) return element._prototypeEventID[0]; (element is null error) if I step past it and submit the second form I get the same error again Unfortunately I don't know why both errors are caused, can you help please? On Aug 5, 9:40 pm, DJ Mangus d.man...@gmail.com wrote: Are you getting any Javascript errors? Note: firefox and firebug is your friend. Don't forget to break on all errors. On Wed, Aug 5, 2009 at 11:22 AM, Ashashley.kenner...@gmail.com wrote: Hi, I wasn't sure whether you meant in the 1st or second function, but it doesn't make a difference in either. I think it is the Event.observe('password-form', 'submit', callProcBasketPassword); which is not working properly, although I don't know how to debug it On Aug 5, 6:48 pm, DJ Mangus d.man...@gmail.com wrote: Try adding e.preventDefault(); instead of Event.stop(e) and let me know if that works? On Tue, Aug 4, 2009 at 4:55 PM, Ashashley.kenner...@gmail.com wrote: function callProcBasketEmail(e) { var pars = Form.serialize('email-form'); var myAjax = new Ajax.Updater('email-response', 'procBasketEmail.php', { method: 'post', parameters: pars, onSuccess: function(response) { Event.observe('password-form', 'submit', callProcBasketPassword); } }); Event.stop(e); } --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Browser scroller position after Ajax.Update
Thank you for your solution, but instead I changed a href=# to a href=javascript:null() and it works like a charm. On Aug 5, 11:00 pm, Alex McAuley webmas...@thecarmarketplace.com wrote: Nope... If you are observing the click with observe() just call Event.stop(event); on it Example. $('myHref').observe('click',function(event) { Event.stop(event); Your ajax code here. }); That way it will degrade in browsers not having javascript and they will just goto the href of the link. HTH Alex Mcauleyhttp://www.thevacancymarket.com - Original Message - From: DJJQ joll...@hotmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Wednesday, August 05, 2009 9:42 PM Subject: [Proto-Scripty] Re: Browser scroller position after Ajax.Update Yes that's right. Maybe that's the problem, should I javascript:null it? On Aug 5, 10:40 pm, Alex McAuley webmas...@thecarmarketplace.com wrote: what does the link look like ? a href=# Click me/a Like that ? Alex Mcauleyhttp://www.thevacancymarket.com - Original Message - From: DJJQ joll...@hotmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Wednesday, August 05, 2009 9:33 PM Subject: [Proto-Scripty] Re: Browser scroller position after Ajax.Update Oh my god my english was terrible in my post, sorry about that. I'll try to explain the problem again: On my php page I have a link a long way down the page, so users have to scroll down a bit. the link triggers an ajax.update on the page. When users press the link the browser returns to the top of the page. How do I restore the browser position to where the link is? (So the scroller position remains unchanged when calling ajax update) On Aug 5, 9:45 pm, Alex McAuley webmas...@thecarmarketplace.com wrote: Can you explain it a bit better please... i cant really understand what you mean by that Thanks Alex Mcauleyhttp://www.thevacancymarket.com - Original Message - From: DJJQ joll...@hotmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Wednesday, August 05, 2009 8:22 PM Subject: [Proto-Scripty] Browser scroller position after Ajax.Update Hello. My problem when is apparent on my page. The div to be updated (and link) are a long way down the page so users have to scroll down. When they press the link and thus update the div the browsers scroller returns to top, forcing the user to scroll down again to the div. Is there any quickfix (like option I have missed) or more advanced solution? Best Regards and Thanks in Advance, Joel --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Beginners question, trouble with Event.stop in AJAX
That seems to be working! Is Event.observe.defer a standard method, or is it only to be used in certain cases? I'm happy that it's working but I would really like to learn the basics properly. Thanks anyway for getting me up and running! Ashley On Aug 5, 10:32 pm, DJ Mangus d.man...@gmail.com wrote: good question. You might change Event.observe( . . . etc to Event.observe.defer( . . . and see if that fixes it. Odd that the node isn't available in the DOM at onSuccess but that might work around it while I research. On Wed, Aug 5, 2009 at 2:22 PM, Ashashley.kenner...@gmail.com wrote: yes, when I check the HTML tab, the form with the id=password-form has not been created within the email-response div, even though I have waited to check for it with the onSuccess line EG function callProcBasketEmail(e) { var pars = Form.serialize('email-form'); var myAjax = new Ajax.Updater('email-response', 'procBasketEmail.php', { method: 'post', parameters: pars, onSuccess: function(response) { Event.observe('password-form', 'submit', callProcBasketPassword); } }); Event.stop(e); } Once I jump past the error, the email-response div gets populated with the form i'm trying to observe, so the question is, why is the onSuccess running before the DOM has been updated? On Aug 5, 10:17 pm, DJ Mangus d.man...@gmail.com wrote: actually just checked firebug, best place would be html tab. DOM tab lists the entire DOM which would be very hard to go through. On Wed, Aug 5, 2009 at 2:12 PM, Ashashley.kenner...@gmail.com wrote: Sorry, i'm quite new to this, should I be looking for the form id=password-form element in the DOM, not sure where to look for it in the DOM tab of firebug? Is this correct? On Aug 5, 10:06 pm, DJ Mangus d.man...@gmail.com wrote: nods when Firebug breaks on the error, check the DOM tab to see the state at that particular moment. On Wed, Aug 5, 2009 at 2:05 PM, Alex McAuleywebmas...@thecarmarketplace.com wrote: Seems the element does not exist... Does it exist in the DOM ? Alex Mcauley http://www.thevacancymarket.com - Original Message - From: Ash ashley.kenner...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Wednesday, August 05, 2009 10:04 PM Subject: [Proto-Scripty] Re: Beginners question, trouble with Event.stop in AJAX When I set firebug to break on all errors... Submit the first form and I get (from prototype.js) function getEventID(element) { element is null3936 if (element._prototypeEventID) return element._prototypeEventID[0]; (element is null error) if I step past it and submit the second form I get the same error again Unfortunately I don't know why both errors are caused, can you help please? On Aug 5, 9:40 pm, DJ Mangus d.man...@gmail.com wrote: Are you getting any Javascript errors? Note: firefox and firebug is your friend. Don't forget to break on all errors. On Wed, Aug 5, 2009 at 11:22 AM, Ashashley.kenner...@gmail.com wrote: Hi, I wasn't sure whether you meant in the 1st or second function, but it doesn't make a difference in either. I think it is the Event.observe('password-form', 'submit', callProcBasketPassword); which is not working properly, although I don't know how to debug it On Aug 5, 6:48 pm, DJ Mangus d.man...@gmail.com wrote: Try adding e.preventDefault(); instead of Event.stop(e) and let me know if that works? On Tue, Aug 4, 2009 at 4:55 PM, Ashashley.kenner...@gmail.com wrote: function callProcBasketEmail(e) { var pars = Form.serialize('email-form'); var myAjax = new Ajax.Updater('email-response', 'procBasketEmail.php', { method: 'post', parameters: pars, onSuccess: function(response) { Event.observe('password-form', 'submit', callProcBasketPassword); } }); Event.stop(e); } --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Browser scroller position after Ajax.Update
The only problem with that solution is you provide no degradation to people without javascript. On 8/5/09, DJJQ joll...@hotmail.com wrote: Thank you for your solution, but instead I changed a href=# to a href=javascript:null() and it works like a charm. On Aug 5, 11:00 pm, Alex McAuley webmas...@thecarmarketplace.com wrote: Nope... If you are observing the click with observe() just call Event.stop(event); on it Example. $('myHref').observe('click',function(event) { Event.stop(event); Your ajax code here. }); That way it will degrade in browsers not having javascript and they will just goto the href of the link. HTH Alex Mcauleyhttp://www.thevacancymarket.com - Original Message - From: DJJQ joll...@hotmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Wednesday, August 05, 2009 9:42 PM Subject: [Proto-Scripty] Re: Browser scroller position after Ajax.Update Yes that's right. Maybe that's the problem, should I javascript:null it? On Aug 5, 10:40 pm, Alex McAuley webmas...@thecarmarketplace.com wrote: what does the link look like ? a href=# Click me/a Like that ? Alex Mcauleyhttp://www.thevacancymarket.com - Original Message - From: DJJQ joll...@hotmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Wednesday, August 05, 2009 9:33 PM Subject: [Proto-Scripty] Re: Browser scroller position after Ajax.Update Oh my god my english was terrible in my post, sorry about that. I'll try to explain the problem again: On my php page I have a link a long way down the page, so users have to scroll down a bit. the link triggers an ajax.update on the page. When users press the link the browser returns to the top of the page. How do I restore the browser position to where the link is? (So the scroller position remains unchanged when calling ajax update) On Aug 5, 9:45 pm, Alex McAuley webmas...@thecarmarketplace.com wrote: Can you explain it a bit better please... i cant really understand what you mean by that Thanks Alex Mcauleyhttp://www.thevacancymarket.com - Original Message - From: DJJQ joll...@hotmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Wednesday, August 05, 2009 8:22 PM Subject: [Proto-Scripty] Browser scroller position after Ajax.Update Hello. My problem when is apparent on my page. The div to be updated (and link) are a long way down the page so users have to scroll down. When they press the link and thus update the div the browsers scroller returns to top, forcing the user to scroll down again to the div. Is there any quickfix (like option I have missed) or more advanced solution? Best Regards and Thanks in Advance, Joel -- Sent from my mobile device --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Beginners question, trouble with Event.stop in AJAX
Ajax is Asyncronous so it gets executed along with other script ... ergo its not serial like php and other stuff your prolly used to... you can make a request synconous (script waits for the ajax request to finish before continuing but its not recommended Alex Mcauley http://www.thevacancymarket.com - Original Message - From: Ash ashley.kenner...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Wednesday, August 05, 2009 10:37 PM Subject: [Proto-Scripty] Re: Beginners question, trouble with Event.stop in AJAX That seems to be working! Is Event.observe.defer a standard method, or is it only to be used in certain cases? I'm happy that it's working but I would really like to learn the basics properly. Thanks anyway for getting me up and running! Ashley On Aug 5, 10:32 pm, DJ Mangus d.man...@gmail.com wrote: good question. You might change Event.observe( . . . etc to Event.observe.defer( . . . and see if that fixes it. Odd that the node isn't available in the DOM at onSuccess but that might work around it while I research. On Wed, Aug 5, 2009 at 2:22 PM, Ashashley.kenner...@gmail.com wrote: yes, when I check the HTML tab, the form with the id=password-form has not been created within the email-response div, even though I have waited to check for it with the onSuccess line EG function callProcBasketEmail(e) { var pars = Form.serialize('email-form'); var myAjax = new Ajax.Updater('email-response', 'procBasketEmail.php', { method: 'post', parameters: pars, onSuccess: function(response) { Event.observe('password-form', 'submit', callProcBasketPassword); } }); Event.stop(e); } Once I jump past the error, the email-response div gets populated with the form i'm trying to observe, so the question is, why is the onSuccess running before the DOM has been updated? On Aug 5, 10:17 pm, DJ Mangus d.man...@gmail.com wrote: actually just checked firebug, best place would be html tab. DOM tab lists the entire DOM which would be very hard to go through. On Wed, Aug 5, 2009 at 2:12 PM, Ashashley.kenner...@gmail.com wrote: Sorry, i'm quite new to this, should I be looking for the form id=password-form element in the DOM, not sure where to look for it in the DOM tab of firebug? Is this correct? On Aug 5, 10:06 pm, DJ Mangus d.man...@gmail.com wrote: nods when Firebug breaks on the error, check the DOM tab to see the state at that particular moment. On Wed, Aug 5, 2009 at 2:05 PM, Alex McAuleywebmas...@thecarmarketplace.com wrote: Seems the element does not exist... Does it exist in the DOM ? Alex Mcauley http://www.thevacancymarket.com - Original Message - From: Ash ashley.kenner...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Wednesday, August 05, 2009 10:04 PM Subject: [Proto-Scripty] Re: Beginners question, trouble with Event.stop in AJAX When I set firebug to break on all errors... Submit the first form and I get (from prototype.js) function getEventID(element) { element is null3936 if (element._prototypeEventID) return element._prototypeEventID[0]; (element is null error) if I step past it and submit the second form I get the same error again Unfortunately I don't know why both errors are caused, can you help please? On Aug 5, 9:40 pm, DJ Mangus d.man...@gmail.com wrote: Are you getting any Javascript errors? Note: firefox and firebug is your friend. Don't forget to break on all errors. On Wed, Aug 5, 2009 at 11:22 AM, Ashashley.kenner...@gmail.com wrote: Hi, I wasn't sure whether you meant in the 1st or second function, but it doesn't make a difference in either. I think it is the Event.observe('password-form', 'submit', callProcBasketPassword); which is not working properly, although I don't know how to debug it On Aug 5, 6:48 pm, DJ Mangus d.man...@gmail.com wrote: Try adding e.preventDefault(); instead of Event.stop(e) and let me know if that works? On Tue, Aug 4, 2009 at 4:55 PM, Ashashley.kenner...@gmail.com wrote: function callProcBasketEmail(e) { var pars = Form.serialize('email-form'); var myAjax = new Ajax.Updater('email-response', 'procBasketEmail.php', { method: 'post', parameters: pars, onSuccess: function(response) { Event.observe('password-form', 'submit', callProcBasketPassword); } }); Event.stop(e); } --~--~-~--~~~---~--~~ 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
[Proto-Scripty] Re: Beginners question, trouble with Event.stop in AJAX
yes but onSuccess shouldn't be called until after the ajax.updater is completed. Therefore the DOM node should be available at that point. On Wed, Aug 5, 2009 at 2:40 PM, Alex McAuleywebmas...@thecarmarketplace.com wrote: Ajax is Asyncronous so it gets executed along with other script ... ergo its not serial like php and other stuff your prolly used to... you can make a request synconous (script waits for the ajax request to finish before continuing but its not recommended Alex Mcauley http://www.thevacancymarket.com - Original Message - From: Ash ashley.kenner...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Wednesday, August 05, 2009 10:37 PM Subject: [Proto-Scripty] Re: Beginners question, trouble with Event.stop in AJAX That seems to be working! Is Event.observe.defer a standard method, or is it only to be used in certain cases? I'm happy that it's working but I would really like to learn the basics properly. Thanks anyway for getting me up and running! Ashley On Aug 5, 10:32 pm, DJ Mangus d.man...@gmail.com wrote: good question. You might change Event.observe( . . . etc to Event.observe.defer( . . . and see if that fixes it. Odd that the node isn't available in the DOM at onSuccess but that might work around it while I research. On Wed, Aug 5, 2009 at 2:22 PM, Ashashley.kenner...@gmail.com wrote: yes, when I check the HTML tab, the form with the id=password-form has not been created within the email-response div, even though I have waited to check for it with the onSuccess line EG function callProcBasketEmail(e) { var pars = Form.serialize('email-form'); var myAjax = new Ajax.Updater('email-response', 'procBasketEmail.php', { method: 'post', parameters: pars, onSuccess: function(response) { Event.observe('password-form', 'submit', callProcBasketPassword); } }); Event.stop(e); } Once I jump past the error, the email-response div gets populated with the form i'm trying to observe, so the question is, why is the onSuccess running before the DOM has been updated? On Aug 5, 10:17 pm, DJ Mangus d.man...@gmail.com wrote: actually just checked firebug, best place would be html tab. DOM tab lists the entire DOM which would be very hard to go through. On Wed, Aug 5, 2009 at 2:12 PM, Ashashley.kenner...@gmail.com wrote: Sorry, i'm quite new to this, should I be looking for the form id=password-form element in the DOM, not sure where to look for it in the DOM tab of firebug? Is this correct? On Aug 5, 10:06 pm, DJ Mangus d.man...@gmail.com wrote: nods when Firebug breaks on the error, check the DOM tab to see the state at that particular moment. On Wed, Aug 5, 2009 at 2:05 PM, Alex McAuleywebmas...@thecarmarketplace.com wrote: Seems the element does not exist... Does it exist in the DOM ? Alex Mcauley http://www.thevacancymarket.com - Original Message - From: Ash ashley.kenner...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Wednesday, August 05, 2009 10:04 PM Subject: [Proto-Scripty] Re: Beginners question, trouble with Event.stop in AJAX When I set firebug to break on all errors... Submit the first form and I get (from prototype.js) function getEventID(element) { element is null3936 if (element._prototypeEventID) return element._prototypeEventID[0]; (element is null error) if I step past it and submit the second form I get the same error again Unfortunately I don't know why both errors are caused, can you help please? On Aug 5, 9:40 pm, DJ Mangus d.man...@gmail.com wrote: Are you getting any Javascript errors? Note: firefox and firebug is your friend. Don't forget to break on all errors. On Wed, Aug 5, 2009 at 11:22 AM, Ashashley.kenner...@gmail.com wrote: Hi, I wasn't sure whether you meant in the 1st or second function, but it doesn't make a difference in either. I think it is the Event.observe('password-form', 'submit', callProcBasketPassword); which is not working properly, although I don't know how to debug it On Aug 5, 6:48 pm, DJ Mangus d.man...@gmail.com wrote: Try adding e.preventDefault(); instead of Event.stop(e) and let me know if that works? On Tue, Aug 4, 2009 at 4:55 PM, Ashashley.kenner...@gmail.com wrote: function callProcBasketEmail(e) { var pars = Form.serialize('email-form'); var myAjax = new Ajax.Updater('email-response', 'procBasketEmail.php', { method: 'post', parameters: pars, onSuccess: function(response) { Event.observe('password-form', 'submit', callProcBasketPassword); } }); Event.stop(e); } --~--~-~--~~~---~--~~ You received this message because
[Proto-Scripty] Re: Class with Ajax and onclick event
I figured it out. I understand that the extra argument will be null because it doesn't exist when the link is being clicked. The solution I found was to make my own attribute count for the a element: a href= count=#number. This attribute can be read by using readAttribute in the changeContent function. After I will figure out how to make the content change automatically (to simulate the clicking on 1 2 3 4 5 6) I will post here the finished class. Maybe it can be used by JS beginners like me to do something similar or maybe someone will use in this form. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Beginners question, trouble with Event.stop in AJAX
I wonder why in this case, that onSuccess is executed before the DOM node has been created. Using a hack is okay to get me up and running but I would like to know how to use ajax methods correctly On Aug 5, 10:48 pm, DJ Mangus d.man...@gmail.com wrote: yes but onSuccess shouldn't be called until after the ajax.updater is completed. Therefore the DOM node should be available at that point. On Wed, Aug 5, 2009 at 2:40 PM, Alex McAuleywebmas...@thecarmarketplace.com wrote: Ajax is Asyncronous so it gets executed along with other script ... ergo its not serial like php and other stuff your prolly used to... you can make a request synconous (script waits for the ajax request to finish before continuing but its not recommended Alex Mcauley http://www.thevacancymarket.com - Original Message - From: Ash ashley.kenner...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Wednesday, August 05, 2009 10:37 PM Subject: [Proto-Scripty] Re: Beginners question, trouble with Event.stop in AJAX That seems to be working! Is Event.observe.defer a standard method, or is it only to be used in certain cases? I'm happy that it's working but I would really like to learn the basics properly. Thanks anyway for getting me up and running! Ashley On Aug 5, 10:32 pm, DJ Mangus d.man...@gmail.com wrote: good question. You might change Event.observe( . . . etc to Event.observe.defer( . . . and see if that fixes it. Odd that the node isn't available in the DOM at onSuccess but that might work around it while I research. On Wed, Aug 5, 2009 at 2:22 PM, Ashashley.kenner...@gmail.com wrote: yes, when I check the HTML tab, the form with the id=password-form has not been created within the email-response div, even though I have waited to check for it with the onSuccess line EG function callProcBasketEmail(e) { var pars = Form.serialize('email-form'); var myAjax = new Ajax.Updater('email-response', 'procBasketEmail.php', { method: 'post', parameters: pars, onSuccess: function(response) { Event.observe('password-form', 'submit', callProcBasketPassword); } }); Event.stop(e); } Once I jump past the error, the email-response div gets populated with the form i'm trying to observe, so the question is, why is the onSuccess running before the DOM has been updated? On Aug 5, 10:17 pm, DJ Mangus d.man...@gmail.com wrote: actually just checked firebug, best place would be html tab. DOM tab lists the entire DOM which would be very hard to go through. On Wed, Aug 5, 2009 at 2:12 PM, Ashashley.kenner...@gmail.com wrote: Sorry, i'm quite new to this, should I be looking for the form id=password-form element in the DOM, not sure where to look for it in the DOM tab of firebug? Is this correct? On Aug 5, 10:06 pm, DJ Mangus d.man...@gmail.com wrote: nods when Firebug breaks on the error, check the DOM tab to see the state at that particular moment. On Wed, Aug 5, 2009 at 2:05 PM, Alex McAuleywebmas...@thecarmarketplace.com wrote: Seems the element does not exist... Does it exist in the DOM ? Alex Mcauley http://www.thevacancymarket.com - Original Message - From: Ash ashley.kenner...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Wednesday, August 05, 2009 10:04 PM Subject: [Proto-Scripty] Re: Beginners question, trouble with Event.stop in AJAX When I set firebug to break on all errors... Submit the first form and I get (from prototype.js) function getEventID(element) { element is null3936 if (element._prototypeEventID) return element._prototypeEventID[0]; (element is null error) if I step past it and submit the second form I get the same error again Unfortunately I don't know why both errors are caused, can you help please? On Aug 5, 9:40 pm, DJ Mangus d.man...@gmail.com wrote: Are you getting any Javascript errors? Note: firefox and firebug is your friend. Don't forget to break on all errors. On Wed, Aug 5, 2009 at 11:22 AM, Ashashley.kenner...@gmail.com wrote: Hi, I wasn't sure whether you meant in the 1st or second function, but it doesn't make a difference in either. I think it is the Event.observe('password-form', 'submit', callProcBasketPassword); which is not working properly, although I don't know how to debug it On Aug 5, 6:48 pm, DJ Mangus d.man...@gmail.com wrote: Try adding e.preventDefault(); instead of Event.stop(e) and let me know if that works? On Tue, Aug 4, 2009 at 4:55 PM, Ashashley.kenner...@gmail.com wrote: function callProcBasketEmail(e) { var pars = Form.serialize('email-form'); var myAjax = new
[Proto-Scripty] Re: Browser scroller position after Ajax.Update
pretty much yes but some shut it off for security reasons On Wed, Aug 5, 2009 at 3:01 PM, DJJQjoll...@hotmail.com wrote: Ok. I thought everyone had javscript by now :) On Aug 5, 11:39 pm, DJ Mangus d.man...@gmail.com wrote: The only problem with that solution is you provide no degradation to people without javascript. On 8/5/09, DJJQ joll...@hotmail.com wrote: Thank you for your solution, but instead I changed a href=# to a href=javascript:null() and it works like a charm. On Aug 5, 11:00 pm, Alex McAuley webmas...@thecarmarketplace.com wrote: Nope... If you are observing the click with observe() just call Event.stop(event); on it Example. $('myHref').observe('click',function(event) { Event.stop(event); Your ajax code here. }); That way it will degrade in browsers not having javascript and they will just goto the href of the link. HTH Alex Mcauleyhttp://www.thevacancymarket.com - Original Message - From: DJJQ joll...@hotmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Wednesday, August 05, 2009 9:42 PM Subject: [Proto-Scripty] Re: Browser scroller position after Ajax.Update Yes that's right. Maybe that's the problem, should I javascript:null it? On Aug 5, 10:40 pm, Alex McAuley webmas...@thecarmarketplace.com wrote: what does the link look like ? a href=# Click me/a Like that ? Alex Mcauleyhttp://www.thevacancymarket.com - Original Message - From: DJJQ joll...@hotmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Wednesday, August 05, 2009 9:33 PM Subject: [Proto-Scripty] Re: Browser scroller position after Ajax.Update Oh my god my english was terrible in my post, sorry about that. I'll try to explain the problem again: On my php page I have a link a long way down the page, so users have to scroll down a bit. the link triggers an ajax.update on the page. When users press the link the browser returns to the top of the page. How do I restore the browser position to where the link is? (So the scroller position remains unchanged when calling ajax update) On Aug 5, 9:45 pm, Alex McAuley webmas...@thecarmarketplace.com wrote: Can you explain it a bit better please... i cant really understand what you mean by that Thanks Alex Mcauleyhttp://www.thevacancymarket.com - Original Message - From: DJJQ joll...@hotmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Wednesday, August 05, 2009 8:22 PM Subject: [Proto-Scripty] Browser scroller position after Ajax.Update Hello. My problem when is apparent on my page. The div to be updated (and link) are a long way down the page so users have to scroll down. When they press the link and thus update the div the browsers scroller returns to top, forcing the user to scroll down again to the div. Is there any quickfix (like option I have missed) or more advanced solution? Best Regards and Thanks in Advance, Joel -- Sent from my mobile device --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Beginners question, trouble with Event.stop in AJAX
OK, just checked the source. onComplete is where ajax.updater actually updates the node. onSuccess is called before that. Workaround is to either a.) use defer like you did, or b.) use Ajax.request and update it yourself onSuccess, then do your Event.observe. Plusses of option b is that it won't try and update anything upon a failed ajax request. On Wed, Aug 5, 2009 at 3:03 PM, Ashashley.kenner...@gmail.com wrote: I wonder why in this case, that onSuccess is executed before the DOM node has been created. Using a hack is okay to get me up and running but I would like to know how to use ajax methods correctly On Aug 5, 10:48 pm, DJ Mangus d.man...@gmail.com wrote: yes but onSuccess shouldn't be called until after the ajax.updater is completed. Therefore the DOM node should be available at that point. On Wed, Aug 5, 2009 at 2:40 PM, Alex McAuleywebmas...@thecarmarketplace.com wrote: Ajax is Asyncronous so it gets executed along with other script ... ergo its not serial like php and other stuff your prolly used to... you can make a request synconous (script waits for the ajax request to finish before continuing but its not recommended Alex Mcauley http://www.thevacancymarket.com - Original Message - From: Ash ashley.kenner...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Wednesday, August 05, 2009 10:37 PM Subject: [Proto-Scripty] Re: Beginners question, trouble with Event.stop in AJAX That seems to be working! Is Event.observe.defer a standard method, or is it only to be used in certain cases? I'm happy that it's working but I would really like to learn the basics properly. Thanks anyway for getting me up and running! Ashley On Aug 5, 10:32 pm, DJ Mangus d.man...@gmail.com wrote: good question. You might change Event.observe( . . . etc to Event.observe.defer( . . . and see if that fixes it. Odd that the node isn't available in the DOM at onSuccess but that might work around it while I research. On Wed, Aug 5, 2009 at 2:22 PM, Ashashley.kenner...@gmail.com wrote: yes, when I check the HTML tab, the form with the id=password-form has not been created within the email-response div, even though I have waited to check for it with the onSuccess line EG function callProcBasketEmail(e) { var pars = Form.serialize('email-form'); var myAjax = new Ajax.Updater('email-response', 'procBasketEmail.php', { method: 'post', parameters: pars, onSuccess: function(response) { Event.observe('password-form', 'submit', callProcBasketPassword); } }); Event.stop(e); } Once I jump past the error, the email-response div gets populated with the form i'm trying to observe, so the question is, why is the onSuccess running before the DOM has been updated? On Aug 5, 10:17 pm, DJ Mangus d.man...@gmail.com wrote: actually just checked firebug, best place would be html tab. DOM tab lists the entire DOM which would be very hard to go through. On Wed, Aug 5, 2009 at 2:12 PM, Ashashley.kenner...@gmail.com wrote: Sorry, i'm quite new to this, should I be looking for the form id=password-form element in the DOM, not sure where to look for it in the DOM tab of firebug? Is this correct? On Aug 5, 10:06 pm, DJ Mangus d.man...@gmail.com wrote: nods when Firebug breaks on the error, check the DOM tab to see the state at that particular moment. On Wed, Aug 5, 2009 at 2:05 PM, Alex McAuleywebmas...@thecarmarketplace.com wrote: Seems the element does not exist... Does it exist in the DOM ? Alex Mcauley http://www.thevacancymarket.com - Original Message - From: Ash ashley.kenner...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Wednesday, August 05, 2009 10:04 PM Subject: [Proto-Scripty] Re: Beginners question, trouble with Event.stop in AJAX When I set firebug to break on all errors... Submit the first form and I get (from prototype.js) function getEventID(element) { element is null3936 if (element._prototypeEventID) return element._prototypeEventID[0]; (element is null error) if I step past it and submit the second form I get the same error again Unfortunately I don't know why both errors are caused, can you help please? On Aug 5, 9:40 pm, DJ Mangus d.man...@gmail.com wrote: Are you getting any Javascript errors? Note: firefox and firebug is your friend. Don't forget to break on all errors. On Wed, Aug 5, 2009 at 11:22 AM, Ashashley.kenner...@gmail.com wrote: Hi, I wasn't sure whether you meant in the 1st or second function, but it doesn't make a difference in either. I think it is the Event.observe('password-form', 'submit', callProcBasketPassword); which is not working
[Proto-Scripty] Re: Beginners question, trouble with Event.stop in AJAX
Do you mean to use function callProcBasketEmail(e) { var pars = Form.serialize('email-form'); var myAjax = new Ajax.Updater('email-response', 'procBasketEmail.php', { method: 'post', parameters: pars, onComplete: function(response) { Event.observe('password-form', 'submit', callProcBasketPassword); } }); Event.stop(e); } rather than testing for onSuccess? On Aug 5, 11:07 pm, DJ Mangus d.man...@gmail.com wrote: OK, just checked the source. onComplete is where ajax.updater actually updates the node. onSuccess is called before that. Workaround is to either a.) use defer like you did, or b.) use Ajax.request and update it yourself onSuccess, then do your Event.observe. Plusses of option b is that it won't try and update anything upon a failed ajax request. On Wed, Aug 5, 2009 at 3:03 PM, Ashashley.kenner...@gmail.com wrote: I wonder why in this case, that onSuccess is executed before the DOM node has been created. Using a hack is okay to get me up and running but I would like to know how to use ajax methods correctly On Aug 5, 10:48 pm, DJ Mangus d.man...@gmail.com wrote: yes but onSuccess shouldn't be called until after the ajax.updater is completed. Therefore the DOM node should be available at that point. On Wed, Aug 5, 2009 at 2:40 PM, Alex McAuleywebmas...@thecarmarketplace.com wrote: Ajax is Asyncronous so it gets executed along with other script ... ergo its not serial like php and other stuff your prolly used to... you can make a request synconous (script waits for the ajax request to finish before continuing but its not recommended Alex Mcauley http://www.thevacancymarket.com - Original Message - From: Ash ashley.kenner...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Wednesday, August 05, 2009 10:37 PM Subject: [Proto-Scripty] Re: Beginners question, trouble with Event.stop in AJAX That seems to be working! Is Event.observe.defer a standard method, or is it only to be used in certain cases? I'm happy that it's working but I would really like to learn the basics properly. Thanks anyway for getting me up and running! Ashley On Aug 5, 10:32 pm, DJ Mangus d.man...@gmail.com wrote: good question. You might change Event.observe( . . . etc to Event.observe.defer( . . . and see if that fixes it. Odd that the node isn't available in the DOM at onSuccess but that might work around it while I research. On Wed, Aug 5, 2009 at 2:22 PM, Ashashley.kenner...@gmail.com wrote: yes, when I check the HTML tab, the form with the id=password-form has not been created within the email-response div, even though I have waited to check for it with the onSuccess line EG function callProcBasketEmail(e) { var pars = Form.serialize('email-form'); var myAjax = new Ajax.Updater('email-response', 'procBasketEmail.php', { method: 'post', parameters: pars, onSuccess: function(response) { Event.observe('password-form', 'submit', callProcBasketPassword); } }); Event.stop(e); } Once I jump past the error, the email-response div gets populated with the form i'm trying to observe, so the question is, why is the onSuccess running before the DOM has been updated? On Aug 5, 10:17 pm, DJ Mangus d.man...@gmail.com wrote: actually just checked firebug, best place would be html tab. DOM tab lists the entire DOM which would be very hard to go through. On Wed, Aug 5, 2009 at 2:12 PM, Ashashley.kenner...@gmail.com wrote: Sorry, i'm quite new to this, should I be looking for the form id=password-form element in the DOM, not sure where to look for it in the DOM tab of firebug? Is this correct? On Aug 5, 10:06 pm, DJ Mangus d.man...@gmail.com wrote: nods when Firebug breaks on the error, check the DOM tab to see the state at that particular moment. On Wed, Aug 5, 2009 at 2:05 PM, Alex McAuleywebmas...@thecarmarketplace.com wrote: Seems the element does not exist... Does it exist in the DOM ? Alex Mcauley http://www.thevacancymarket.com - Original Message - From: Ash ashley.kenner...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Wednesday, August 05, 2009 10:04 PM Subject: [Proto-Scripty] Re: Beginners question, trouble with Event.stop in AJAX When I set firebug to break on all errors... Submit the first form and I get (from prototype.js) function getEventID(element) { element is null3936 if (element._prototypeEventID) return element._prototypeEventID[0]; (element is null error) if I step past it and submit the second form I get the same error again
[Proto-Scripty] Re: Beginners question, trouble with Event.stop in AJAX
I honestly think the defer is best at this point as oncomplete occurs even on failed requests. Your choices are to rewrite your own stuff instead of prototype functions (ie. Do your own success checks or do your own updating) or just stick with defer. On 8/5/09, Ash ashley.kenner...@gmail.com wrote: Do you mean to use function callProcBasketEmail(e) { var pars = Form.serialize('email-form'); var myAjax = new Ajax.Updater('email-response', 'procBasketEmail.php', { method: 'post', parameters: pars, onComplete: function(response) { Event.observe('password-form', 'submit', callProcBasketPassword); } }); Event.stop(e); } rather than testing for onSuccess? On Aug 5, 11:07 pm, DJ Mangus d.man...@gmail.com wrote: OK, just checked the source. onComplete is where ajax.updater actually updates the node. onSuccess is called before that. Workaround is to either a.) use defer like you did, or b.) use Ajax.request and update it yourself onSuccess, then do your Event.observe. Plusses of option b is that it won't try and update anything upon a failed ajax request. On Wed, Aug 5, 2009 at 3:03 PM, Ashashley.kenner...@gmail.com wrote: I wonder why in this case, that onSuccess is executed before the DOM node has been created. Using a hack is okay to get me up and running but I would like to know how to use ajax methods correctly On Aug 5, 10:48 pm, DJ Mangus d.man...@gmail.com wrote: yes but onSuccess shouldn't be called until after the ajax.updater is completed. Therefore the DOM node should be available at that point. On Wed, Aug 5, 2009 at 2:40 PM, Alex McAuleywebmas...@thecarmarketplace.com wrote: Ajax is Asyncronous so it gets executed along with other script ... ergo its not serial like php and other stuff your prolly used to... you can make a request synconous (script waits for the ajax request to finish before continuing but its not recommended Alex Mcauley http://www.thevacancymarket.com - Original Message - From: Ash ashley.kenner...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Wednesday, August 05, 2009 10:37 PM Subject: [Proto-Scripty] Re: Beginners question, trouble with Event.stop in AJAX That seems to be working! Is Event.observe.defer a standard method, or is it only to be used in certain cases? I'm happy that it's working but I would really like to learn the basics properly. Thanks anyway for getting me up and running! Ashley On Aug 5, 10:32 pm, DJ Mangus d.man...@gmail.com wrote: good question. You might change Event.observe( . . . etc to Event.observe.defer( . . . and see if that fixes it. Odd that the node isn't available in the DOM at onSuccess but that might work around it while I research. On Wed, Aug 5, 2009 at 2:22 PM, Ashashley.kenner...@gmail.com wrote: yes, when I check the HTML tab, the form with the id=password-form has not been created within the email-response div, even though I have waited to check for it with the onSuccess line EG function callProcBasketEmail(e) { var pars = Form.serialize('email-form'); var myAjax = new Ajax.Updater('email-response', 'procBasketEmail.php', { method: 'post', parameters: pars, onSuccess: function(response) { Event.observe('password-form', 'submit', callProcBasketPassword); } }); Event.stop(e); } Once I jump past the error, the email-response div gets populated with the form i'm trying to observe, so the question is, why is the onSuccess running before the DOM has been updated? On Aug 5, 10:17 pm, DJ Mangus d.man...@gmail.com wrote: actually just checked firebug, best place would be html tab. DOM tab lists the entire DOM which would be very hard to go through. On Wed, Aug 5, 2009 at 2:12 PM, Ashashley.kenner...@gmail.com wrote: Sorry, i'm quite new to this, should I be looking for the form id=password-form element in the DOM, not sure where to look for it in the DOM tab of firebug? Is this correct? On Aug 5, 10:06 pm, DJ Mangus d.man...@gmail.com wrote: nods when Firebug breaks on the error, check the DOM tab to see the state at that particular moment. On Wed, Aug 5, 2009 at 2:05 PM, Alex McAuleywebmas...@thecarmarketplace.com wrote: Seems the element does not exist... Does it exist in the DOM ? Alex Mcauley http://www.thevacancymarket.com - Original Message - From: Ash ashley.kenner...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Wednesday, August 05, 2009 10:04 PM Subject: [Proto-Scripty] Re: Beginners question, trouble with Event.stop in AJAX When I set firebug to break
[Proto-Scripty] How to catch/prevent onclick event?
Hi I have observer set for the whole document to catch click events on links (a href) and prevent default action (open page from href, event.stop). It works correct, but ... now I have onclick event defined inside of each a-herf element and I need to catch/prevent this event too. How to do that? I'm hope it's quite clear ;) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] HTTP OPTION REQUEST with FireFox 3.5
Hi All, I have a strange behavior with a pice of code I wrote using the latest prototype release, here it is: == var debug = $('debug'); new Ajax.Request(http://twitter.com/statuses/ public_timeline.json, { method: 'get', onLoading: function(){ debug.update('Loading...'); }, onSuccess: function(transport) { debug.update(SUCCESS: + transport.responseJSON + br/ ); }, onException: function(transport, exception){ debug.update(EXCEPTION: + exception); } }); == What is happening here is that I'm doing an HTTP OPTION request instead of a HTTP GET request and I believe it is because of this: http://hacks.mozilla.org/2009/07/cross-site-xmlhttprequest-with-cors/ but anyway I don't know how to manage/avoid it. I just want to make an AJAX request using HTTP GET. Can anyone help me? Many thanks, Omar --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] function in prototype
Dear all I am new to javascript and prototype. I have difficulty in writing function() in prototype because I am confused that function can be one of the parameter..i.e. some_function(abc, function()) I have the following code, the two observe functions actually doing the same thing, only with different attributes...I don't know how to start to write a function for that so my code is less duplication...Please give me some hints on that. Thank you. script type=text/javascript charset=utf-8 var checkboxes1 = $$(input[id=cluster_code_]); var cbControl1 = $(all_cluster_selector); cbControl1.observe(click, function(){ checkboxes1.each(function(box){ box.checked = cbControl1.checked; }); }); var checkboxes2 = $$(input[id=hosp_code_]); var cbControl2 = $(all_hospital_selector); cbControl2.observe(click, function(){ checkboxes2.each(function(box){ box.checked = cbControl2.checked; }); }); /script Many thanks Valentino --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: How to catch/prevent onclick event?
Best to try removing those at dom:loaded, maybe with something like this: document.observe('dom:loaded',function(){ $$(a).each(function(elm){elm.onclick = null}); }); That's just a guess... But as far as I know, you can't stop these inline event handlers any other way. Walter On Aug 4, 2009, at 6:21 PM, Hipnotik wrote: Hi I have observer set for the whole document to catch click events on links (a href) and prevent default action (open page from href, event.stop). It works correct, but ... now I have onclick event defined inside of each a-herf element and I need to catch/prevent this event too. How to do that? I'm hope it's quite clear ;) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: HTTP OPTION REQUEST with FireFox 3.5
Unless you work at Twitter, this will run afoul of the Single Origin Policy, and you can't do this. (Ajax requests have to stick to the domain and port that they are run from for their content.) If you create a simple proxy and run it on your server, then you could request /mytwitterproxy.php from your server with impunity. Walter On Aug 5, 2009, at 5:30 PM, 0m4r wrote: Hi All, I have a strange behavior with a pice of code I wrote using the latest prototype release, here it is: == var debug = $('debug'); new Ajax.Request(http://twitter.com/statuses/ public_timeline.json, { method: 'get', onLoading: function(){ debug.update('Loading...'); }, onSuccess: function(transport) { debug.update(SUCCESS: + transport.responseJSON + br/ ); }, onException: function(transport, exception){ debug.update(EXCEPTION: + exception); } }); == What is happening here is that I'm doing an HTTP OPTION request instead of a HTTP GET request and I believe it is because of this: http://hacks.mozilla.org/2009/07/cross-site-xmlhttprequest-with-cors/ but anyway I don't know how to manage/avoid it. I just want to make an AJAX request using HTTP GET. Can anyone help me? Many thanks, Omar --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: How to catch/prevent onclick event?
Hi, One of the few good things about those old-style handlers is that they're attributes, so finding the links is easy: var hookedlinks = $$('a[onclick]'); Then if your goal is to remove the handler: var n; for (n = hookedlinks.length - 1; n = 0; --n) { hookedlinks[n].onclick = null; } Or you can have more fun, I wrote this up a while back to convert DOM0 handlers into modern ones and optionally put some pre-condition logic in place prior to firing the DOM0 handler: * * * * (also at http://pastie.org/573599) function wrapDom0Handler(elm, evtname) { var propname, dom0handler; // Grab the current DOM0 handler for the event propname = on + evtname; dom0handler = elm[propname]; // Clear it elm[propname] = null; // Hook up your handler elm.observe(evtname, function(event) { var rv; alert(TODO: Your optional precondition logic goes here); // Chain to the DOM0 handler, if any if (Object.isString(dom0handler)) { rv = eval(dom0handler); } else if (Object.isFunction(dom0handler)) { rv = dom0handler.call(elm, event); } if (!Object.isUndefined(rv) !rv) { // Handler returned something falsey, cancel event.stop(); } }); } * * * * HTH, -- T.J. Crowder tj / crowder software / com Independent Software Engineer, consulting services available On Aug 4, 11:21 pm, Hipnotik pork...@gmail.com wrote: Hi I have observer set for the whole document to catch click events on links (a href) and prevent default action (open page from href, event.stop). It works correct, but ... now I have onclick event defined inside of each a-herf element and I need to catch/prevent this event too. How to do that? I'm hope it's quite clear ;) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---