私はGrailsを初めて使用するので、ご容赦ください。
私のビューには次のようなJavaScriptコードがあります:
//js code in my View
function validateEmailAndSetEmail(){
var result =${remoteFunction(controller:'myController',action:'validateEmail',update:'responseDiv', params:'\'email=\'+document.getElementById(\'email\').value')};
if (result) { //doSomething}
}
私のコントローラーは次のようになります。
def validateEmail = {
def emailToValidate = request.getParameter("email")
def matchingEmailFound = myService.checkEmailAddress(emailToValidate)
if (matchingEmailFound){
render "This email is already in use.<br>If you have already created an account with this email, please try to reset the password from Login page."}
else{
//setEmail to send here
render "This email is not in use. This email will be used as your account email"}
return !matchingEmailFound
私の質問には2つの部分があります。
ファイアバグからのjsコードの結果の値を調べると、ブール型(true / false)ではなく、値が正しくないようですが、コントローラーからのビューでこの値をjsに正しく渡す方法はありますか?
set email valueをコントローラーの変数に呼び出して、ビューのjsの外部で呼び出すことはできますか?
前もって感謝します。