Custom jquery - Seamless play
November 18, 2022 12:00 AM
Hello all,
I'm wondering how you target the pageDIV in seamless play to add classes?
Solution
Take a look at this, it may help while waiting for an answer.
JQuery and Seamless Play — ROCKSTARS Community (elearningbrothers.com)
Containing your containers: Custom JavaScript Suggestions for Lectora Online (elblearning.com)
Discussion (5)
Hi Andrew,
That didn't work for me. I'm guessing they way it's handled is different since 2015. For the jquery function for getDisplayWindow, triv$(getDisplayWindow()).find('p').css('background-color','red'); works for me when testing, but it looks like none of the other functions listed in the reference is available.
Any ideas?
I'll also need to use something like the getCurrentPageID because for normal publish, the ID is pageDIV, but not for seamless.
Take a look at this, it may help while waiting for an answer.
JQuery and Seamless Play — ROCKSTARS Community (elearningbrothers.com)
Containing your containers: Custom JavaScript Suggestions for Lectora Online (elblearning.com)
Hi Andrew,
I've actually got all of my code written and working when not publishing with seamless, but have to rewrite to use Lectora's JQuery because publishing to seamless puts my code in the wrong place to access the page objects. Side note, the only reason I'm doing this is because I only need to publish with seamless since we have audio that is set for autoplay. Unless it is published with seamless, Firefox and mobile delivery has tap/click to continue prompt on every page. If anyone has a solution for non-seamless publish, that would be the best, then no rewriting would be needed.
I'm not having a problem using the same type of code you are using to access the items on the page itself, but I need to access the containing div (which is the pageDIV in non-seamless publishing, and a unique page number with seamless.
The following does work when not published with seamless.
triv$("#pageDIV").addClass("maindiv");
The div I'm trying to target with seamless does have a class of .pageDIV, but using the following does not work.
triv$(".pageDIV").addClass("maindiv");
From my experience, it is still relative. The group here on the forum helped me create the following code that I use to dynamically get the ID of an object based on the CSS class. It helps when trying to do advanced JavaScript work.
//Gets the item's ID using the class name.
function getIdFromClass(_classIn){
let uniqueID = triv$(_classIn, getDisplayDocument()).first().attr("id");
return uniqueID;
}
Are you remembering to add the triv$ in front of any/all JavaScript you are using (of course unless you including your own version of JQuery manually)? Do you have sample code available that you are trying to use?
The solution that worked for me was:
$('#'+GetCurrentPageID(),getDisplayDocument()).addClass("maindiv");
Note: In the documentation, getCurrentPageID() and getCurrentPageDiv(), the "get" should be capitalized "Get".