BookmarkSubscribeRSS Feed
bheinsius
Lapis Lazuli | Level 10
Hi,

I created a new tagset called "ivb" with parent=tagsets.html4.
This tagset adds some javascript in the doc_head event.

Now I want to "subclass" the ivb tagset to add some extra javascript.
In the subclass I notice that the parent's doc_head event is overriden by the child's.
Is there a way to call the parent's doc_head event from the child?

-Bart
3 REPLIES 3
Cynthia_sas
SAS Super FREQ
Hi:
I'm not exactly sure what you mean by "subclass" but if your new template inherits from the parent of "ivb", then it will have the changed (or child) DOC_HEAD event. If your new template inherits from a parent of tagsets.html4, then you will have the original DOC_HEAD event.

A template can only have 1 parent. So when you use PARENT=IVB, if IVB has PARENT=TAGSETS.HTML4, all inheritance between IVB and HTML4 is resolved before IVB becomes the new parent.

One thing you might consider is having the DOC_HEAD event in each template trigger a new event, which will only write the JAVASCRIPT you want...something like this:
[pre]
define tagset ivb;
parent=tagsets.html4;
define event doc_head;
..... whatever you want here or just copy original ....
...... but add your own "trigger" statement ....
trigger ivb_js;
end;
define event ivb_js;
....your "ivb" javascript stuff is here...
end;
[/pre]

and then your new "subclass" tagset template:
[pre]
define tagset subclass;
parent=tagsets.ivb;

define event ivb_js;
** what is here overrides what is in tagsets.ivb;
trigger sub_js;
end;
define event sub_js;
... put your subclass javascript here ...
end;
[/pre]

Or, alternately, just have the "subclass" tagset template inherit from tagsets.html4 instead of from tagsets.ivb:
[pre]
define tagset subclass;
parent=tagsets.html4;
define event doc_head;
..... whatever you want here or just copy original ....
...... but add your own "trigger" statement ....
trigger sub_js;
end;
define event sub_js;
....your "subclass" javascript stuff is here...
end;
[/pre]


I haven't tested it out, since I don't know enough JavaScript to be useful, but an approach like this might do what you want, depending on what you mean by "subclass".

cynthia
Eric_SAS
SAS Employee
I understand your pain completely. Unfortunately the tagset language does not have the ability to sub class or call a parent's event. I have wanted this ability for a long time, but have never managed to get around to it. Inheritance is rather simplistic, but very straight forward.

The method that Cynthia outlined is the easiest way. Create a new event in the parent, or in your's that does the functionality you need so it won't be over written by the child tagset.

The initialize event in the html and Excel tagsets does this sort of thing. Since initialize is an ODS event, over riding it and keeping some or all of the parent's functionality can be a pain. So all it does is trigger other events that do the actual work. It's a whole lot easier to copy that, and use the sub-events than if it were to have a bunch of tagset code in it.
bheinsius
Lapis Lazuli | Level 10
Hi Cynthia@SAS and Eric@SAS,

Thanks for your suggestions.
Sounds like a solution that will work!

Thanks,
-Bart

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1234 views
  • 0 likes
  • 3 in conversation