On Jan 15, 2008, at 8:53 PM, user splash wrote:
{
return false;
onFailure: function(){ alert(‘Unable to submit task.’) },
onException: function(o,e) { alert(e) }
});
return false; ////////IS IT RIGHT TO RETURN FALSE HERE TO
PREVENT THE
FORM FROM BEING SUBMITED TWICE?
}
}
Hm. Please don’t take offense to this, but you might be in over your
head right now. I posted that function as an example of what you
can do. I didn’t intend for you to try to use it verbatim in your
code. You were having a problem getting all of your form fields to
make it across to your controller. This method was shown to give you
an example of how to serialize a form.
But to answer some of your questions…
var f = $(‘submit_task_form’); assigns the form to the local variable
f. $() is a Prototype function. f will be passed to other functions
to do things that I need to do. In my original message, I mentioned
that there were a few functions that you didn’t need to pay attention
to.
/wgg/submit_task is an action in a controller in my application. You
would use whatever action you post your form to.
the “return false” at the end of the function is not sufficient to
prevent double submission of the form. You would need to include
“return false” in the event handler that calls the javascript function:
onclick=“some_function(); return false;”
Let me ask you a question: have you spent much time working through
any tutorials? How about the Agile Web D. with Rails book?
I don’t mean to criticize you, especially for being new to RoR, but
it seems to me like you have a lack of understanding of the
fundamentals of Javascript and RoR. Trying to take someone else’s
code, offered as an example, and just drop it into your application
and hope it works is rarely going to get you the results you desire.
I am pretty new to RoR. It’s been about 9 months now. I started
with the above mentioned book and worked on a piddly little app, just
to get my bearings. I’ve been working on some “real apps” now for a
few months, and I’m learning more and more every day. While not
technically mind-boggling, some of the things I’m doing are not going
to make a whole lot of sense to someone who is not yet versed in the
interaction between Javascript and RoR.
Please, for your own good, step back from this project and think
about what you are trying to accomplish. Take a little time and work
through some things, step by step, until you get a feel for how it
all works. You’ll save yourself a whole bunch of hair pulling. Really.
Peace,
Phillip