Problem with Token replacements or custom Javascript

mmackinnon2873
mmackinnon2873 Community Member Posts: 6 ☆ Roadie ☆
I am experimenting with integrating javascript and jQuery functionality into Lecotra modules. The end goal is to create template type activities (Quizes, Drag and Drops etc.) that are easy to add, change and remove content to reuse over and over.

Currently the issue is that Token replacement (Help Page) isn't working when it is inside a 'runJavascript' action attached to an object in Lectora. When I try to publish out the module to HTML the page fails to load in my browser giving me a "Uncaught SyntaxError: Unexpected token %" Error.

The replacement does work when it is inside an ExternalHTMLObject, and when I find that object in my element inspector in chrome I can see that lectora has removed '%HTMLNAME%' and replaced it with the appropriate html name.

I am hoping that someone may have some insight into why Lectora is not handling the %HTMLNAME% token correctly.

I am running Lectora v12.1.4

Comments

  • timk
    timk Community Member Posts: 1,207 ♦ Idol ♦
    Hi ,

    can you post the exact code of your action? The "%" shouldn't be in it any more when the browser loads the page. I've tested with some very basic code in a Run javascript action:

    alert("%HTMLNAME%");

    The %HTMLNAME% is replaced during publication so the code of the action in the html page is:

    alert("button89");

    Maybe you have some quotes in unexpected places...

    Tim
  • mmackinnon2873
    mmackinnon2873 Community Member Posts: 6 ☆ Roadie ☆
    Hi Tim,

    After copy and pasting your code
    alert("%HTMLNAME%");

    into a runJavascript Action that is triggered when you click an image I receive an alert box that says:

    This Page says:

    %HTMLNAME%

    So it appears like Lectora isn't replacing the tokens when it publishes the module.
  • timk
    timk Community Member Posts: 1,207 ♦ Idol ♦
    I tested with Lectora 16.1.2, maybe it's new. My test in Lectora 12.1.4 has the same result that you describe.
  • mmackinnon2873
    mmackinnon2873 Community Member Posts: 6 ☆ Roadie ☆
    Ah well Thanks for you help anyway. If the issue is reproducible in your version of 12.1.4 at least that means I'm not going crazy. It is frustrating to have the Official Help Docs say something is supported but in actuality it is not.
  • ssneg
    ssneg Community Member Posts: 1,466 ☆ Roadie ☆
    Works for me in 16.2.2. I added an "On Show - Run JS" action to an image on a page, and %HTMLNAME% was replaced with "image47". When I attached same action to a page, it just said "%HTMLNAME%" so I guess it only works for some objects.
  • timk
    timk Community Member Posts: 1,207 ♦ Idol ♦
    It should work for all objects to be replaced with the html name / id of the div. The page itself has no id / html name, so it won't work.
  • ssneg
    ssneg Community Member Posts: 1,466 ☆ Roadie ☆
  • timk
    timk Community Member Posts: 1,207 ♦ Idol ♦
    Ok, but the id of the page is always "pageDIV"...

    Can you select the html name with the keyboard again in 16.2.2?

     
  • ssneg
    ssneg Community Member Posts: 1,466 ☆ Roadie ☆
    No, only with mouse. Tabbing skips the field with the name.
  • klaatu
    klaatu Community Member Posts: 988
    How can I get the HTML Name via keyboard?
  • klaatu
    klaatu Community Member Posts: 988
    Whoops, nevermind, I see you updated your post.