Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

webrobert's avatar

TributeJs intercept event?

Anyone use Tribute by chance?

Instead of showing "no matches" I have modified the noMatchTemplate to act as an add option. The only problem is Tribute is listening for the click event and it creates an error in the console.

Is there a way to intercept that? Everything else works. Just a console error. I have tried prevent on the click event stop prop etc. but they are too late.

noMatchTemplate: function () {
    return '<span>' +
        '<button onclick="window.Livewire.emit(\'addCompany\'); this.remove()" ' +
        'class="p-3 block bg-red-50 rounded-md cursor-pointer">Add</button>' +
    '</span>';
},

https://github.com/zurb/tribute/blob/master/src/Tribute.js

and the click event... https://github.com/zurb/tribute/blob/master/src/TributeEvents.js#L82

or can I catch the error it throws?

  throw new Error("cannot find the <li> container for the click");
0 likes
1 reply
webrobert's avatar
webrobert
OP
Best Answer
Level 51

javascript is not my favorite place. but I was able to suppress it using a global error handler on that page...

onerror = handleErr;

function handleErr(msg, url, line_no)
{
    if('Error: cannot find the <li> container for the click' === msg) {
        return true
    }
}

any other error will still hits the console.

Please or to participate in this conversation.