Page 1 of 1
How to Execute JS action on an Html link Click
Posted: Thu Apr 18, 2013 5:18 pm
by leonardo
I wonder how to achieve getting an html link to trigger a JS action rather than the usual url target action. What I need to do is to get JS to collect data from an xml rest service and do something with it. Thanks.
How to Execute JS action on an Html link Click
Posted: Thu Apr 18, 2013 6:48 pm
by Maryna Brodina
If you don't need to navigate to another site after you click on Link component, you can just use Label component.
How to Execute JS action on an Html link Click
Posted: Thu Apr 18, 2013 7:45 pm
by leonardo
There would be many links in body of the html rendered within the component. Can I still use the Label component to do that and render it as html? How is the link captured and sent to JS?
How to Execute JS action on an Html link Click
Posted: Thu Apr 18, 2013 9:08 pm
by Maryna Brodina
Sorry, not sure I understand. Could you explain in more details please?
How to Execute JS action on an Html link Click
Posted: Thu Apr 18, 2013 10:34 pm
by leonardo
I'm sorry Marina. I mean the html text that i will put on either the Label or Panel component will have many links within, not just one. Can I use Label component to render such html text with multiple links. Regardless of whether I use Label or Panel, how can I call JS on a link click action instead of navigating to a url?
How to Execute JS action on an Html link Click
Posted: Thu Apr 18, 2013 10:49 pm
by maxkatz
Use Run JavaScript action. There you can run any JavaScript.
http://docs.appery.io/documentation/a...
How to Execute JS action on an Html link Click
Posted: Thu Apr 18, 2013 10:50 pm
by Igor
HI,
You can use Textarea component.
Create javascript function on separate js file.
precode
$(function() {
$("#linkclick").click(function(e) {
// methods to call...
});
});
/code/pre
then use this function on html link
precode
<a id="linkclick" href="http://jquery.com">jquery</a>
/code/pre