VR Course Contest


Show us your best virtual reality course and win $50 gift card and a winner badge!
CHECK IT OUT

Changing the HTML name of an object

sirwise23
sirwise23 Community Member Posts: 442
I am pretty sure the answer is no, but is there any way to change the HTML name of an object?

I have done it by editing the HTML files int he back end but I really wish there was a way to do this in the GUI.

There are times that I may copy an object from another course that may have a JavaScript call or an HTML code happening, and instead of just changing the HTML name of an object, I have to go and change all of the code to match the new random generated name.

Comments

  • ssneg
    ssneg Community Member Posts: 1,466
    Instead of addressing objects by their HTML names (which are random and cannot be set by you) in your code, you should address them by class name (which can be assigned by you to any object in Lectora). Then your JS objects will always be reusable.
  • rd4384
    rd4384 Community Member Posts: 8
    @sirwise23 I assign the html names to variables in my external JavaScript files so that I don't have to remember the cumbersome names Lectora generates. For example, when using jQuery, I would do something similar to the following:

    var game = $('#image1972'); //Store game image element ID
  • jvalley4735
    jvalley4735 Community Member Posts: 1,357
    For most objects, you can rename the HTML name by going to the objects Properties and from the Image group selecting the arrow in the bottom right-hand corner. This opens an expanded description of the object where you can add a long description for 508 or update the HTML name.
  • timk
    timk Community Member Posts: 1,147 ✶ Headliner ✶
    Esp. if you want to use Renotas approach it may be possible to use the token replacement Math describes here:

    http://community.trivantis.com/forums/topic/javascript-and-htmlnames/

    It can be done by running the code in a Run javascript action added to the game image

    On: Page show
    Action: Run javascript
    Javascript:

    var game = $("#%HTMLNAME%");

    During Publication Lectora will replace %HTMLNAME% with the html name / the id of the object the action is added to.

    Tim
  • timk
    timk Community Member Posts: 1,147 ✶ Headliner ✶
    Hi Jenni,

    have you ever been able to actually change the html name of an object? Lectora won't let me edit the field... and it still won't let me select the html name with the keyboard / tab key.

    Tim
  • jvalley4735
    jvalley4735 Community Member Posts: 1,357
    That's strange.  I'm running v16 but yes I can.  Let me try with 12.
  • jvalley4735
    jvalley4735 Community Member Posts: 1,357
    I uploaded the same image and checked. Confirmed, I can do it from 12.1.4.  You might want to open a support ticket and see if something's disconnected on your back end.
  • ssneg
    ssneg Community Member Posts: 1,466
    Lectora 16.0.2 - I can select and copy HTML name of object but I cannot edit the names. I don't think I ever could. Jenny, can you please upload a screenshot of editing the name? E.g. before and after, in the same title, same object?
  • jvalley4735
    jvalley4735 Community Member Posts: 1,357
    I don't know why I had it stuck in my head that I could edit it! LOL I cannot edit the field.  The Lectora Information Center says "The HTML name is assigned when you add the object. The HTML name, which is used to identify the object, cannot be changed." I think it's time for some more coffee this morning.....
  • ssneg
    ssneg Community Member Posts: 1,466
    It's just wishful thinking :) Everybody wants to be able to edit HTML names!!! :D
  • klaatu
    klaatu Community Member Posts: 988
    You can re-assign the numeral part of the HTML Name (id) but not the characters. If you write your external code accordingly, this could give you the control you are looking for.

    1. Add the object(s) you want to rename to your project but do not add actions to them yet.
    2. Make a note of the HTML name that was automatically assigned.
    3. Save the project and close Lecotra.
    4. Open the .awt in a text editor (notepad works fine - use open with..).
    5. Find the line that assigns the ID, example <shape id="49" parent="2" ontop="false" proportional="false">
    6. Change the number in the parentheses <shape id="995" parent="2" ontop="false" proportional="false"> (Here I changed "49" to "995".)
    7. Save the file and re-open in Lectora. Your object now has the name you assigned.

    You can do this any time you add an object as long as you have not used it in any actions.

    Darrel
  • mnotermans5114
    mnotermans5114 Community Member Posts: 916
    In Lectora itself you cannot edit ( maybe change parts like Darrel suggest..didnot check that ) the html names....
    however if needed...

    You can open the .awt in any text-editor that supports xml.... find the html-names you want to change...and name them exactly as you want.

    My setup for creating Lectora .awt from a .PSD does exactly that...create a Lectora .awt with custom html names.
  • klaatu
    klaatu Community Member Posts: 988
    Did you read my post?
  • mnotermans5114
    mnotermans5114 Community Member Posts: 916
    Apparently not good enough, cause now noticing its the same method ;-) Stupid me :-)

    In Fact you can even do this when actions are assigned, but you have to find the proper action and retarget that to your newly created htmlname
  • sirwise23
    sirwise23 Community Member Posts: 442
    Thanks, the opening of an AWT file in a text editor should work well. I will give it a shot. Mostly I have only needed to do this with videos. I tend to use actions on a button to make a video skip to a certain time in the video.
  • tmichael9734
    tmichael9734 Community Member Posts: 93
    Darrel,

    Is there a way to change the HTML name for a button after adding an action?  Your instructions are before adding an action, but 508 needs me to add the button HTML name after I completed the training.
  • carlfink
    carlfink Community Member Posts: 744 ✶ Headliner ✶
    I'm not Darrel, but completing the training is not adding an action, and 508 would not require you to change a button's name in any case. Maybe it's alt-text?
Sign In or Register to comment.

So You Wanna Be An eLearning ROCKSTAR?

We're all fans of eLearning here! Want to become an eLearning ROCKSTAR? Just click on one of the buttons below to start your rocking journey!