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?

5
  • 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? Commented Nov 7, 2017 at 5: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.? Commented Nov 7, 2017 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. Commented Nov 7, 2017 at 16:13
  • Why can't you use a tag, that will give you the functionality you want? Commented Nov 7, 2017 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". Commented Nov 7, 2017 at 16:27

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.