Services have the onAccept() and onReject() callbacks. There is no such things at the category level. The application has the onConsent() event.
The sequence of events occurs as follow:
1) service onAccept()
2) script execution for the enabled categories or services (ex <script type="text/plain" data-category="necessary">...</script>)
3) app event onConsent()
This is problematic if we want to do something when a category is accepted, before related scripts execution.
I am aware of two workarounds:
1) don't prevent scripts execution, but rather add, within the scripts, an onConsent() event listener and when the desired category is received, run the code. (see this post)
The limitations of this approach are the non negligible extra code (vs simply adding a data-category attribute to an existing script), and the difficulties if a script execution should be impacted by the accepted/rejected status of multiple categories.
2) add a single service to the category.
This limitation is more graphical than else, we now have 2 accepted/rejected sliders for the same category, as depicted here
Proposed solution
I propose to add the onAccept() and onReject() callbacks to the categories.
Alternatively, the app onConsent() event should be fired before executing the scripts associated with allowed categories or services .
Description
V3.0.0
Services have the
onAccept()
andonReject()
callbacks. There is no such things at the category level. The application has theonConsent()
event.The sequence of events occurs as follow: 1) service
onAccept()
2) script execution for the enabled categories or services (ex<script type="text/plain" data-category="necessary">...</script>
) 3) app eventonConsent()
This is problematic if we want to do something when a category is accepted, before related scripts execution.
I am aware of two workarounds: 1) don't prevent scripts execution, but rather add, within the scripts, an
onConsent()
event listener and when the desired category is received, run the code. (see this post) The limitations of this approach are the non negligible extra code (vs simply adding adata-category
attribute to an existing script), and the difficulties if a script execution should be impacted by the accepted/rejected status of multiple categories. 2) add a single service to the category. This limitation is more graphical than else, we now have 2 accepted/rejected sliders for the same category, as depicted hereProposed solution
I propose to add the
onAccept()
andonReject()
callbacks to the categories.Alternatively, the app
onConsent()
event should be fired before executing the scripts associated with allowed categories or services .Additional details
No response