We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

AjaxForm | Forum

Eric
Eric Sep 7 '11
I have a form in a plugin that is in an overlay. I'm using setAjax and when it submits I don't want it to call another page, I just want it to run a javascript function. Is there an example of this anywhere? I couldn't find anything in the docs.

I assume that I use $form->setAction(), but I need the action to be javascript.
Sardar
Sardar Sep 8 '11
Hi Eric,
Default ajax forms work with php responder in any case, and `$form->setAction()` used to set the responder url. As I understand you want to send all the form data using your custom js function. If yes, you can override form default submit handler using jquery:

$('#formId').unbind(submit).bind('submit', function(){
//my actions
}
);
Make sure your bind code is executed after core binds and don't forget to set formId. Also you can get form DOM link here `window.owForms['formName'].form`. If you have any other questions feel free to ask!
The Forum post is edited by Sardar Sep 8 '11
Eric
Eric Sep 12 '11
Thanks for the info. This might be a silly question, but I can't seem to find the answer. How do I set the form ID? I see it has a name attribute, but no id.
Sardar
Sardar Sep 13 '11
You can set the form ID using setter `setId('myId')` (works for all form elements).
Looks like you don't have code completion in your editor, try this one http://netbeans.org/downloads/index.html (it's absolutely free).
The Forum post is edited by Sardar Sep 13 '11
Eric
Eric Sep 13 '11
Thanks. I've used netbeans before. I'll have to try it out again.
Michael I.
Michael I. Dec 18 '12
Topic was moved from Plugins.