Hi Sriram,

I'm glad I'm not the only one using iUI with Groovy Templates and/or Gaelyk!

I don't think your issues are related to Groovy, but would occur in a static .html file as well. There can be issues with .gtpl files where the $ character used as the syntax for substituting Groovy variables interferes with a $ character in your JavaScript. This happens with jQuery and you'll need to use \$ when you are referencing jQuery.

I think that the 2nd problem you were having is that the href string does not execute JavaScript code. You should be able to put cs_func back into your gtpl file. You also should be able to set the href attribute to a string with a resolved toggleVal in your onclick handler and return true to have the default action use the updated href value.

Good luck!

Sean


sri wrote:
Hi,

I got it to work. I had to define a separate JS file and call the
function on click event in the button.

so, in my case, I had a file cs.js

function cs_func()
{
      var v1 =
document.getElementById("toggleid").getAttribute("toggled");
      var url = "up.groovy?toggleval=";
      url += v1;
      location.href = url;
}

In my up.gtpl file, I made the following:


<a type="button" class="whiteButton" onclick="cs_func()"
href="#">update</a>

This way, I got it to call the servlet with the actual toggle value.

If there is any other easy way, please let me know.

Thanks
Sriram


On May 3, 9:33 am, sri <[email protected]> wrote:
Hi,

I have a script (.gtpl) that has a toggle button snippet. I have an
onClick=alert(message), which works fine. But if I replace alert with
my function, it does not get called.

The objective is to check whether the toggle button was clicked and
change the 'ON" to OFF (if it was previously ON) in a variable.

I looked at ibm developer's site. The code there gives script errors.

Thanks much for your help
Sriram

--
You received this message because you are subscribed to the Google Groups 
"iPhoneWebDev" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group 
athttp://groups.google.com/group/iphonewebdev?hl=en.


--
You received this message because you are subscribed to the Google Groups 
"iPhoneWebDev" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/iphonewebdev?hl=en.

Reply via email to