cordova - phonegap, jquery: function for <a> -
<a href="http://stackoverflow.com/" class="link" id="4" >stackoverflow</a> <script> $('.link').click(function(){ var idx = $(this).attr('id'); visit(idx); }) </script>
i want make function run before browser opened.
the function visit() defined , doesn't have error.
for reason, visit(idx) ignored.
can give me hints?
you have prevent default behaviour of clicked link:
$('.link').click(function(e){ e.preventdefault(); var idx = this.id; visit(idx); })
now depending visit()
function doing, can after completes (i guess async method), redirect browser specific link done clicking on former link.
for example, inside click handler , supposing visit()
returns promise (ajax request e.g):
visit(idx).always(function(){this.click();}.bind(this));
or using window.location = this.href;
but more specific help, need post visit()
method code in question itself.
Comments
Post a Comment