retrieving class

Workarounds and usability notes.

retrieving class

Postby John Robin Dove » Sun Aug 07, 2016 7:35 am

Hi Clifton,

Any idea why this is happening?
Image

Image

I am trying to get the CSS class (which is "pause3") and I get it twice!
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am

Re: retrieving class

Postby Clifton » Sun Aug 07, 2016 8:42 am

How are you assigning the class name to the [name of target] object?

It is possible to set class names multiple times. You can check whether this has happened by using Firebug in Firefox to examine your exported content. However, if you use userProperty() to set the class name, it should never appear twice.
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am

Re: retrieving class

Postby Clifton » Sun Aug 07, 2016 2:01 pm

UPDATE:
Apparently, userProperty() can potentially set a class name multiple times on an object. I consider this a bug (though it has no negative impact on how your content runs), but it will be fixed in PowerPac v13.x. No more updates will be pushed out to the v12.x series so if you want to become a beta tester for PowerPac v13.x, then you will get this fix as part of the new version development series.

See this topic for information on the v13.x development initiative:
viewtopic.php?f=9&t=223
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am

Re: retrieving class

Postby John Robin Dove » Tue Aug 09, 2016 3:44 am

Hi Clifton,

Thanks. I was using userProperty() to set the class. It's not a great problem I just use If myClass contains ... instead of If my class = ... and for the moment this works fine.

I would certainly like to be a beta tester for v13.x. The testing in browser option sounds great.

By the way how do you deal with the fact that browsers normally use cached copies of html documents and don't always use the latest version? On Firefox I clear the history every time I test my program but I usually use Google Chrome in incognito mode which prevents it from keeping copies. Is there a better solution?
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am

Re: retrieving class

Postby John Robin Dove » Fri Aug 12, 2016 4:04 am

Hi Clifton,

As it happened, this exposed a weakness in my program. Because the tbk is now seriously full of code (I have reached the limit, I think), I load several secondary TB DHTML components into fields using pgGotoURL. The last of these sends a trigger to an object in the main window using onFirstIdle and pgExecuteRemote. This allows the final part of my loading process (loading a video file, showing more objects etc.) to complete successfully. For some unknown reason this trigger was being sent twice. I have found a solution. I now use a global Boolean loadSent to prevent this happening more than once. The loading is now faster and the classes are only defined once.
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am

Re: retrieving class

Postby Clifton » Fri Aug 12, 2016 10:53 am

Glad you discovered the problem. At any rate, the userProperty() should protect against multiple assignments of the same class as this can cause issues when actually using multiple classes, which the PowerPac does when manipulating web fonts.

But this is fixed in the v13.x development series.
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am

Re: retrieving class

Postby John Robin Dove » Mon Aug 15, 2016 12:00 pm

Hi Clifton,

The saga continues. The object was being triggered twice because the 'secondary TB DHTML' was being loaded twice. I have 2 large programs: MDCTV1 and MDCTV2. MDCTV1 loads MDCTV2 so I checked that MDCTV1 only executes pgGotoURL once. I load a lot of DHTML and HTML files into fields in MDCTV2 as you can see in the picture.

Image

What I can't understand is why the loadSent condition does not work in this case. An aggravating factor is that MDCTV2 is seriously overloaded. It is almost impossible to modify it and still be able to export it to DHTML. I have tried to offload more code into external js files but so far I have not been successful. b.js functions but c.js doesn't.
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am

Re: retrieving class

Postby Clifton » Mon Aug 15, 2016 4:05 pm

At first glance, there may be a problem with when loadSent gets set to true. If it is set to true when the page loads in the pgGotoURL() function execution, then the variable will not be set properly. It will appear true ONLY in the namespace of the new url. I would make sure to set the variable in the same namespace where it will evaluate its condition or value . . . which would only apply to the book that is actually loading the url with pgGotoURL().

Sometimes, these things can get a little sticky when you have load events going on in multiple locations. The key is to keep track of what namespace contains the variable you are evaluating in your actions. Just because a variable is global, does not mean it is recognized in a different html document.
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am

Re: retrieving class

Postby John Robin Dove » Tue Aug 16, 2016 8:36 am

pgGotoURL does not seem to be the culprit. It is only executed once. The second unwanted load seems to take place within the file being loaded! I have tried: 1) using a global Boolean within the DHTML being loaded 2) using an object property within the DHTML being loaded i.e. setting the text of a field to "done" 3) getting the file being loaded to "write itself a cookie". None of these works. Somehow the loading takes place twice. If it's not pgGotoURL firing twice then it must be the program that's being loaded that somehow sends itself a message to load again!? I have not been able to replicate this behaviour in a test app so it must be something specific to my program environment that causes it. I suppose it doesn't really matter. As far as I can see, only the on load page events are affected.
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am

Re: retrieving class

Postby Clifton » Tue Aug 16, 2016 12:17 pm

If the file that loads is generating an on load event that is fired twice, you might check if there is some logic in some custom js file that is inadvertently sending or handling the on load event. Sometimes, when adding third-party html pages to an application you have to check the js files for document load handlers that escalate their behavior up the document hierarchy.

If pgGotoURL() is loading another ToolBook application, then you should be able to track this down more easily.

As a debug routine, try this with the onFirstIdle() PowerPac function:
    on load page
    onFirstIdle( name of self, "trigger", 10000 ); discard return value;
    Comment: Move all the on load page actions to the trigger event of this page.
    The above function will load the page, detect idle + 10000ms, then fire the trigger event.
    Point: Check whether the page loaded by pgGotoURL() gets loaded twice.
    This should help you narrow down where the event duplication is originating.
    Comment: It is good practice to make discretionary use of onFirstIdle() when loading multiple HTML pages.
    This helps to keep tasks in proper sequence when complex applications are loading content.
Hope this helps. Of course, I may not be understanding your issue completely, but the above may still be useful to you or others.
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am

Next

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 4 guests

cron