Explore the community Forums Lectora Lectora Questions & Answers Problem with Token replacements or custom Javascript

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #327645 Score: 0
    Profile photo of Malcolm MacKinnon
    Malcolm MacKinnon
    Member
    beginner
    intermediate
    curious george
    wise owl
    @mmackinnon2873

    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

    #327660 Score: 0
    Profile photo of Tim K
    Tim K
    Member
    contributor
    beginner
    intermediate
    advanced
    friend finder
    junior moderator
    advocate
    wise owl
    curious george
    Group Member
    354 pts
    @timk

    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

    #327661 Score: 0
    Profile photo of Malcolm MacKinnon
    Malcolm MacKinnon
    Member
    beginner
    intermediate
    curious george
    wise owl
    @mmackinnon2873

    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.

    #327665 Score: 0
    Profile photo of Tim K
    Tim K
    Member
    contributor
    beginner
    intermediate
    advanced
    friend finder
    junior moderator
    advocate
    wise owl
    curious george
    Group Member
    354 pts
    @timk

    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.

    #327666 Score: 0
    Profile photo of Malcolm MacKinnon
    Malcolm MacKinnon
    Member
    beginner
    intermediate
    curious george
    wise owl
    @mmackinnon2873

    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.

    #327684 Score: 0
    Profile photo of Sergey Snegirev
    Sergey Snegirev
    Member
    contributor
    intermediate
    advanced
    friend finder
    lab member
    junior moderator
    advocate
    LUC16
    LUC16 Attendee
    wise owl
    339 pts
    @ssneg

    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.

    #327693 Score: 0
    Profile photo of Tim K
    Tim K
    Member
    contributor
    beginner
    intermediate
    advanced
    friend finder
    junior moderator
    advocate
    wise owl
    curious george
    Group Member
    354 pts
    @timk

    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.

    #327753 Score: 0
    Profile photo of Sergey Snegirev
    Sergey Snegirev
    Member
    contributor
    intermediate
    advanced
    friend finder
    lab member
    junior moderator
    advocate
    LUC16
    LUC16 Attendee
    wise owl
    339 pts
    @ssneg

    But it does 🙂

    #327798 Score: 0
    Profile photo of Tim K
    Tim K
    Member
    contributor
    beginner
    intermediate
    advanced
    friend finder
    junior moderator
    advocate
    wise owl
    curious george
    Group Member
    354 pts
    @timk

    Ok, but the id of the page is always “pageDIV”…

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

     

    #327808 Score: 0
    Profile photo of Sergey Snegirev
    Sergey Snegirev
    Member
    contributor
    intermediate
    advanced
    friend finder
    lab member
    junior moderator
    advocate
    LUC16
    LUC16 Attendee
    wise owl
    339 pts
    @ssneg

    No, only with mouse. Tabbing skips the field with the name.

    #327810 Score: 0
    Profile photo of Darrel Somoza
    Darrel Somoza
    Member
    contributor
    friend finder
    beginner
    intermediate
    junior moderator
    advanced
    wise owl
    curious george
    profile
    209 pts
    @Klaatu

    How can I get the HTML Name via keyboard?

    #327811 Score: 0
    Profile photo of Darrel Somoza
    Darrel Somoza
    Member
    contributor
    friend finder
    beginner
    intermediate
    junior moderator
    advanced
    wise owl
    curious george
    profile
    209 pts
    @Klaatu

    Whoops, nevermind, I see you updated your post.

Viewing 12 posts - 1 through 12 (of 12 total)

You must be logged in to reply to this topic.