• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: JavaScript Problems with AjaxSubmitButton
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: JavaScript Problems with AjaxSubmitButton


  • Subject: Re: JavaScript Problems with AjaxSubmitButton
  • From: Farrukh Ijaz <email@hidden>
  • Date: Sun, 30 May 2010 08:44:40 +0300

Do the following and it will work:

Add a method as follows in your script:

function ajaxCheckValidations(o) {
checkValidations();
return o.form.onsubmit();
}

And change the AjaxSubmitButton binding as follows:

AjaxSubmitButton1: AjaxSubmitButton {
value = "Save";
class = "ok";
onClickBefore = "ajaxCheckValidations(this)";
action = ajaxButtonAction;
evalScripts = true;
}

The reason why it was not working is:

Since WOActiveImage is not an ajax component, it causes the form's onsubmit() event to fire. The validations get fired on form's onsubmit(). In case of AjaxSubmitButton the onsubmit() won't get fired. So you need to trigger it manually as I did in the _javascript_ function. Also you need to use onClickBefore instead of onClick. if the value of onClickBefore is evaluated to true, the action will be called.

I hope this will solve the problem.

I would suggest, if you're using Wonder then try using WOGNL framework and instead of maintaining separate binding files, use <wo: tags. This will make the code easy to read and maintain.

Like e.g. in your html file, instead of using <WEBOBJECT NAME=AjaxSubmitButton1></WEBOBJECT> you can use something as follows:

<wo:AjaxSubmitButton value="Save" class="ok" onClickBefore="ajaxCheckValidations(this)" action="$ajaxButtonAction" evalScripts="$true"/>

Farrukh

On 2010-05-29, at 8:20 PM, Kalpana Vaka wrote:

Hi All,
 
Please find the enclosed compressed file with the sample application that depicts the _javascript_ problems with AjaxSubmitButton.
 
The application has the following components.
 
1) One Text field
2) One WOActiveImage Button
3) Two AjaxSubmitButtons ("Save" & "SecondSave")
4) _javascript_ file that is being used for calling script validations from WOComponent (gen_validatorv2.js).
 
When we click on WOActiveImage without entering anything in the text box then, _javascript_ validation is being executed onClicking the button and form is not getting submitted until we enter valid value in it. It is working fine.
 
And for AjaxSubmitButton1 also, same _javascript_ function has been given for onClick event binding. But, the validation is not getting fired and we are not seing alert window.
 
For both of the above Submit buttons, _javascript_ validations from gen_validatorv2 file are being called.
 
And for AjaxSubmitButton2,  different _javascript_ function is binded to onClick event. This _javascript_ function is not calling any of the methods in gen_validatorv2.js. In this case, we are getting the alert with the validation message. But, form is getting submitted on clicking on the OK button in the alert box.
 
So, finally the issues with AjaxSubmitButtons are summarized below.
 
1) When we use external _javascript_ file (gen_validatorv2.js), we are not getting alert window with the validation failure message and action method is being called.
 
2) When we write _javascript_ function in the WOComponent itself, we are getting alert with the validation failure message. But, the action method is being called in case of validation failure too.
 
Any help in resolving this issue?
 
Thanks & Regards,
Kalpana.
 
 

Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: JavaScript Problems with AjaxSubmitButton
      • From: Kalpana Vaka <email@hidden>
References: 
 >JavaScript Problems with AjaxSubmitButton (From: Kalpana Vaka <email@hidden>)

  • Prev by Date: [SOLVED] Ajax List Filtering
  • Next by Date: Re: ERXRadioButtonMatrix example???
  • Previous by thread: JavaScript Problems with AjaxSubmitButton
  • Next by thread: Re: JavaScript Problems with AjaxSubmitButton
  • Index(es):
    • Date
    • Thread