Lisa7324589
Posts: 0
Joined: Tue Jan 13, 2015 2:10 pm

Open dynamically created links with inAppBrowser

Hi guys.
My app dynamically creates a list of video links by making requests to a website.

I mapped the created URLs to a link component and used this code that I found in another question ( https://getsatisfaction.com/apperyio/... ):

var a = $('a[name=mobilelink_62]');
window.open(a.attr('href'), '_blank', 'location=yes');

as an on click function for a button component. The idea being that when a person clicks the button the video will appear in the inAppBrowser.

The problem is that any button clicked always directs the user to the newest video in the list.

Are you guys able to help me with this problem?

I'm sorry if I haven't explained myself very well!

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Open dynamically created links with inAppBrowser

Hi Lisa,

Yes your code - works only with one link...

But you should use current one..

So here is a solution:

  1. Delete current "click" event handler.

  2. Add "link" component "click" event handler with action "Run Javascript".

  3. Populate it with following JS code:

    pre

    var a = jQuery(this);
    window.open(a.attr('href'), '_blank', 'location=yes');

    //Stop to open current link settings.
    arguments[0].preventDefault();

    /pre

    Regards.

Return to “Issues”