You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Vishal Popat <vi...@cipriati.co.uk> on 2014/06/10 11:28:52 UTC

Ajax Form Submit via jquery plugin / javascript

Hi,

I am using a jquery steps plugin which has the ability to change options.
One of the options I have is:
		onFinished: function (event, currentIndex) {
                    var form = document.forms["selectionForm"];
                    form.submit();
                },

The javascript above submits the associated form. However I would like to submit the form via ajax. Normally I would use an AjaxButton for ajax processing but in this case I need something else. I have tried

selectionForm.add(new AjaxFormSubmitBehavior(selectionForm, "onsubmit") {
	@Override
	protected void onSubmit(AjaxRequestTarget target) {
		log.debug("******* ajax form submit");
	}
}

but this does not seem to work as the debug does not get outputted.
Additionally, the onSubmit Form version is called. Is there a way to stop this?

Let me know if should be using something else instead.

Regards
Vishal
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Ajax Form Submit via jquery plugin / javascript

Posted by Martin Grigorov <mg...@apache.org>.
Hi,



On Tue, Jun 10, 2014 at 11:28 AM, Vishal Popat <vi...@cipriati.co.uk>
wrote:

> Hi,
>
> I am using a jquery steps plugin which has the ability to change options.
> One of the options I have is:
>                 onFinished: function (event, currentIndex) {
>                     var form = document.forms["selectionForm"];
>                     form.submit();
>

Try with:
jQuery("#selectionForm").trigger("submit"); // or
jQuery("#selectionForm").submit() which is a shortcut


>                 },
>
> The javascript above submits the associated form. However I would like to
> submit the form via ajax. Normally I would use an AjaxButton for ajax
> processing but in this case I need something else. I have tried
>
> selectionForm.add(new AjaxFormSubmitBehavior(selectionForm, "onsubmit") {
>         @Override
>         protected void onSubmit(AjaxRequestTarget target) {
>                 log.debug("******* ajax form submit");
>         }
> }
>
> but this does not seem to work as the debug does not get outputted.
> Additionally, the onSubmit Form version is called. Is there a way to stop
> this?
>
> Let me know if should be using something else instead.
>
> Regards
> Vishal
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Ajax Form Submit via jquery plugin / javascript

Posted by vp143 <vi...@cipriati.co.uk>.
I wasnt able to get anything working... I tried adding wicket:id via jquery
to the plugin button but wicket did not recognise it.

However, I had been using wicket 6.7.0 up until then. 
I see that AjaxWizardButtonBar within the Wizard functionality has been
added in a latter wicket version which I had not found when researching.
This solved my problems perfectly!

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Ajax-Form-Submit-via-jquery-plugin-javascript-tp4666170p4666457.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Ajax Form Submit via jquery plugin / javascript

Posted by Paul Bors <pa...@bors.ws>.
Instead of calling form.submit() from your jQuery, call ${‘#someButtonID’}.click() or whatever, then register your event under the button’s onClick in Wicket.
You can have that button shared, or you can write your own Behavior to submit the form via a hidden button (i.e.: X and Y coordinates set to negative so it’s way off the page as well as its display property set to hidden).

Those are just couple of ideas.

On Jun 13, 2014, at 11:45 AM, vp143 <vi...@cipriati.co.uk> wrote:

> Paul Bors wrote
>> http://ci.apache.org/projects/wicket/apidocs/6.0.x/org/apache/wicket/ajax/form/AjaxFormSubmitBehavior.html
>> 
>> "Ajax event behavior that submits a form via ajax when the event it is
>> attached to, is invoked.”
>> 
>> You’re attaching the submit event so who fires that?
> 
> You are right, I missed that but I am still a little stumped on what to do.
> 
> I am assuming the form gets submitted when calling 
> jQuery("#selectionForm").submit()
> 
> I was assuming this part
> add(new AjaxFormSubmitBehavior(this, "onsubmit") { 
> would be waiting for the submit of the form and then get executed.
> 
> Have I understood correctly?
> What am I missing?
> 
> Regards
> Vishal
> 
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Ajax-Form-Submit-via-jquery-plugin-javascript-tp4666170p4666257.html
> Sent from the Users forum mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Ajax Form Submit via jquery plugin / javascript

Posted by vp143 <vi...@cipriati.co.uk>.
Paul Bors wrote
> http://ci.apache.org/projects/wicket/apidocs/6.0.x/org/apache/wicket/ajax/form/AjaxFormSubmitBehavior.html
> 
> "Ajax event behavior that submits a form via ajax when the event it is
> attached to, is invoked.”
> 
> You’re attaching the submit event so who fires that?

You are right, I missed that but I am still a little stumped on what to do.

I am assuming the form gets submitted when calling 
jQuery("#selectionForm").submit()

I was assuming this part
add(new AjaxFormSubmitBehavior(this, "onsubmit") { 
would be waiting for the submit of the form and then get executed.

Have I understood correctly?
What am I missing?

Regards
Vishal

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Ajax-Form-Submit-via-jquery-plugin-javascript-tp4666170p4666257.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Ajax Form Submit via jquery plugin / javascript

Posted by Paul Bors <pa...@bors.ws>.
http://ci.apache.org/projects/wicket/apidocs/6.0.x/org/apache/wicket/ajax/form/AjaxFormSubmitBehavior.html

"Ajax event behavior that submits a form via ajax when the event it is attached to, is invoked.”

You’re attaching the submit event so who fires that?

On Jun 10, 2014, at 5:28 AM, Vishal Popat <vi...@cipriati.co.uk> wrote:

> Hi,
> 
> I am using a jquery steps plugin which has the ability to change options.
> One of the options I have is:
> 		onFinished: function (event, currentIndex) {
>                    var form = document.forms["selectionForm"];
>                    form.submit();
>                },
> 
> The javascript above submits the associated form. However I would like to submit the form via ajax. Normally I would use an AjaxButton for ajax processing but in this case I need something else. I have tried
> 
> selectionForm.add(new AjaxFormSubmitBehavior(selectionForm, "onsubmit") {
> 	@Override
> 	protected void onSubmit(AjaxRequestTarget target) {
> 		log.debug("******* ajax form submit");
> 	}
> }
> 
> but this does not seem to work as the debug does not get outputted.
> Additionally, the onSubmit Form version is called. Is there a way to stop this?
> 
> Let me know if should be using something else instead.
> 
> Regards
> Vishal
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>