1

While using datatables, row can be made clickable by javascript, eg:

    $table.on('click', 'tr td', function (event) {
        var rowData = table.row(this).data();
        if (rowData) {
            window.location = rowData.link
        }
    }

However, this differs from actually having <a>-tags in one important and usability-sensitive way: in many browsers, <a>-links allow users to open links in new tabs and see the url in advance, the right-click menu is totally different, for example, in Firefox.

Is there clever way to do the same in datatables, or is the only possible solution to put <a>-tags around contents of each cell to have the rest of the link behavior?

Roman Susi
  • 4,135
  • 2
  • 32
  • 47
  • Marking a question as duplicate == answer, that there are no better ways than put a-tags around cells' contents without any specifics of this particular question? – Roman Susi Nov 07 '17 at 05:59
  • You're right, after I reread your question, it made more sense. Although you may need to be more clear. Are you just trying to produce links in cells or make whole cell behave as a link, i.e. with right click context menu, etc.? – Gyrocode.com Nov 07 '17 at 15:38
  • Yes. With pure click even trigger browser reacts to click, but does not provide the behavior of the usual link. Asking in hope there is some way. Updated question a little. – Roman Susi Nov 07 '17 at 16:13
  • Why can't you use `a` tag, that will give you the functionality you want? – Gyrocode.com Nov 07 '17 at 16:16
  • I am afraid it will make 100 x 10 cell table less responsive as there will be more markup. Plus, I am curious if there is a way to say the browser "behave as if it were a link". – Roman Susi Nov 07 '17 at 16:27

0 Answers0