It looks like you already know what to do. Putting it on the server side is a bad idea.
The simple argument is that you Javascript lives both on the server side and in separate Javascript files (assuming you use Javascript at all). This can be a nightmare for debugging in order to fix a situation where everything is everywhere.
Unless you use any other Javascript other than server-side scripting, this will probably be fine and manageable (forget that unobtrusive movement says).
Secondly, if you have 100 links per page, you will repeat the same code in 100 places. Repetition is yet another maintenance and debugging nightmare. You can process all links on all pages with one event handler and one attribute. It does not even need a second thought.
<Rant>
Itβs not easy to separate HTML and Javascript and even CSS, especially if you want to improve AJAX or UI. In order to have a complete separation, we would have to switch to a desktop application model, where program code with an interface will be generated on the client side programmatically using Javascript, and all interaction with the server is limited to pure data exchange.
Most upstream messages (client to server) are already just data exchange, but not downlink communications. Many server-side scripts generate HTML, combine it with data, and twirl it back. This is great as long as the server remains on the team for generating HTML views. But when the fantasy Javascript comes on board and starts adding rows to the tables, and the div for comments, replicating the existing HTML structure, then we created two points at which the markup is generated.
$(".comments").append($("<div>", { "id": "123", "class": "comment", "html": "I would argue this is still bad practice..." }));
This may not be such a big nightmare (depending on scale), but it can be a serious problem. Now, if we change the structure of comments, the change should be done in two places - the server side of the script and the templates from which the source content is created, and the Javascript side, which dynamically adds comments after the page loads.
The second example is applications using drag and drag. If you can drag the div around the page, they will need to be removed from the normal page flow and positioned absolutely or relatively with the exact coordinates. Now, since we cannot pre-create classes for all possible coordinates (and it would be foolish to try), we basically introduce styles directly in the element. Our HTML code is as follows:
<div style="position: absolute; top: 100px; left: 250px;">..</div>
We ruined our beautiful semantic pages, but it had to be done.
</Rant>
The semantic and behavioral separation to the side, I would say, basically comes down to repetition. Do you repeat the code unnecessarily. Several levels process the same logic. Is it possible to drag all this into one layer or reduce all repetitions.