Rahul Bhargava
2005-Aug-01 13:57 UTC
[Rails-spinoffs] function.prototype.bind return value?
Quick question - how come the function.prototype.bind doesn''t allow for return values? Am I missing some basic understanding of how this works? I searched and couldn''t find an answer. Specifically, I''m binding an object method to an existing form''s onSubmit, but it still actually submits the form, refreshing the page - which is not what I want. If change Prototype.js''s bind function to this (Adding just that internal return): Function.prototype.bind = function(object) { var __method = this; return function() { return __method.apply(object, arguments); } } And have my object''s method return false, then it does run the onSubmit function I''ve bound in, and it doesn''t submit try to submit the actual form - which is what I want. This is because that return false percolates up to the onSubmit of the form because I''m adding that return statement to bind. Any reason that return statement isn''t in there? Suggestions? Thanks, Rahul
Michael Schuerig
2005-Aug-01 14:19 UTC
[Rails-spinoffs] Re: function.prototype.bind return value?
On Monday 01 August 2005 21:56, Rahul Bhargava wrote:> And have my object''s method return false, then it does run the > onSubmit function I''ve bound in, and it doesn''t submit try to submit > the actual form - which is what I want.This doesn''t answer your original question, but if you want to prevent an event from causing its usual effect, then Event.stop is what you should use. Michael -- Michael Schuerig Nothing is as brilliantly adaptive mailto:michael@schuerig.de as selective stupidity. http://www.schuerig.de/michael/ --A.O. Rorty, The Deceptive Self
Markus Joschko
2005-Aug-02 08:11 UTC
[Rails-spinoffs] Re: function.prototype.bind return value?
Hi Rahul, I''m also missing the possibility to return false. Please post if you found a solution which does not require a change in the prototype library ;-) Greetings, Markus On 8/1/05, Michael Schuerig <michael@schuerig.de> wrote:> On Monday 01 August 2005 21:56, Rahul Bhargava wrote: > > And have my object''s method return false, then it does run the > > onSubmit function I''ve bound in, and it doesn''t submit try to submit > > the actual form - which is what I want. > > This doesn''t answer your original question, but if you want to prevent > an event from causing its usual effect, then Event.stop is what you > should use. > > Michael > > -- > Michael Schuerig Nothing is as brilliantly adaptive > mailto:michael@schuerig.de as selective stupidity. > http://www.schuerig.de/michael/ --A.O. Rorty, The Deceptive Self > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >