11
Elxis 4.x/5.x DEV / Re: Upcoming Elxis 5.6 information
« Last post by datahell on August 13, 2025, 09:29:59 »The CSP option already exists in Elxis configuration since v5.5. However Elxis HTML was not ready for a strict CSP policy. In version 5.6 everything inline removed, even the js events.
Conversion example
Original HTML
<a href="javascript:void(null);" onclick="doSomething();">Do something</a>
New HTML:
<a href="#" id="dolink">Do something</a>
In PHP:
$eDoc->addNativeDocReady('doOnLoad();');
In javascript file:
function doOnLoad() {
document.getElementById('dolink').addEventListener('click', function(e) { e.preventDefault(); doSomething(); });
}
If you have many links executing the same js function it is recommended to use "data-" attributes. Example:
<a href="#" data-something="12">Do 12</a>
<a href="#" data-something="15">Do 15</a>
<a href="#" data-something="18">Do 18</a>
let dnlinks = document.querySelectorAll('a[data-something]');
if (dnlinks.length > 0) {
for (let q=0; q<dnlinks.length; q++) {
dnlinks[q].addEventListener('click', function(e) {
let nid = this.getAttribute('data-something'); e.preventDefault(); doSomething(nid);
});
}
}
Conversion example
Original HTML
<a href="javascript:void(null);" onclick="doSomething();">Do something</a>
New HTML:
<a href="#" id="dolink">Do something</a>
In PHP:
$eDoc->addNativeDocReady('doOnLoad();');
In javascript file:
function doOnLoad() {
document.getElementById('dolink').addEventListener('click', function(e) { e.preventDefault(); doSomething(); });
}
If you have many links executing the same js function it is recommended to use "data-" attributes. Example:
<a href="#" data-something="12">Do 12</a>
<a href="#" data-something="15">Do 15</a>
<a href="#" data-something="18">Do 18</a>
let dnlinks = document.querySelectorAll('a[data-something]');
if (dnlinks.length > 0) {
for (let q=0; q<dnlinks.length; q++) {
dnlinks[q].addEventListener('click', function(e) {
let nid = this.getAttribute('data-something'); e.preventDefault(); doSomething(nid);
});
}
}