Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Twitter Sign In with OpenID Sign In with Google

Sign In Sign Up

In this Discussion

Welcome to the Jo support forums! Please Sign Up and join in the discussion. You can also Sign In instantly with Twitter, OpenID or your Google ID.
Links in joHTML dont work
  • DirkDirk February 2011
    Posts: 5

    Hi,

    i want to load HTML like this:

    var stack = new joStackScroller([ new joCard([ new joHTML("a rel="nofollow" href="http://www.joApp.com'>joApp") ]) ]);

    When i click the link nothing happened.

    Thanks.

    Dirk

  • davedave February 2011
    Posts: 415

    joHTML intercepts any <a> tag links found in the HTML because in some mobile platforms you want to make sure to prevent the user from loading a new page into your current page (e.g. using PhoneGap with Android and iOS).

    You will need to setup a handler for these, something like this:

    // replace this part of your stack code
    new joHTML(
        '<a href="http://joapp.com">joApp</a>'
    ).selectEvent.subscribe(function(href) {
        console.log("Link clicked: " + href);
        // to load that URL into the current page
        document.location = href;
    });
    

    Now, you probably don't want to load that URL on top of your app's page, so instead of document.location you'll probably want to launch that URL into a new browser instance (using PhoneGap or whatever other means your platform of choice allows).

    If you want to load that page into your app inside another joHTML, you'll need to set something up with joFile that creates a new card and adds it to the stack.

    Let me know if you're trying to do that last approach, and I'll look into making a sample app with that functionality.

    Dave Balmer, Jo Code Wrangler
  • DirkDirk February 2011
    Posts: 5

    Hi Dave,

    thanks a lot, this is the way want to build the app. I was hoping there would be a simpler solution, for multiple a-Tags in a joHTML. We create a webApp with jo. It runs fine, fast and is easy to use. The webApp load JSON with joScript and callbacks. Build the cards from the JSON e.g.:

    card:[
      {
        type: "menu",
        data: [
          {
            type:'menuItem',
            data:'1. Item',
            a:'JSON.php?id=2'
          }, 
    ...
    

    than add the card to the stack. So we load joHTML too and want to use the Links. I think the best way is to extract the a-Tags and build joButton or something like that.

    Thanks, Dirk

  • davedave February 2011
    Posts: 415

    Hmm you don't have to extract the a-tags necessarily. The event handler code snippet above just needs to be added to wherever you create your joHTML widget. Actually, you could extend joHTML to do this automatically. Check the source code for joHTML itself, and you can make your own and override the event handler which grabs links. You could make it create a new card and put it on the stack.

    This is one of those cases where you could solve the problem any number of ways, so have fun with it. :)

    Dave Balmer, Jo Code Wrangler