Bug and quick fix for Notes element notes.js

JTe

New Member
There seems to be a small bug in the line 31 of the Notes element file:
plugins/fabrik_element/notes/notes.js

If the user has only a read access to the element, the javascript tries still to add an event to the 'button' element. With the read only access the element does not exist in the HTML code, as it is only included when you have the right to add comments (write access). Because of that the line 31 returns a NULL error.

That can be fixed by replacing line 30 of the notes.js:
Code:
if (this.options.primaryKey > 0) {
with this:
Code:
30 if (this.options.primaryKey > 0 && this.element.getElement('.button')) {

That should be fully safe as the getElement returns NULL if the element is not found in the DOM and otherwise it returns an object reference which is always true.

Do not forget minify or rename the notes.js file to notes-min.js file as the element uses minified versions of the js files.

If I have time I will add the fix to the Github too, but this is for those who want a quick fix.
 
Last edited:
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top