How to AJAX-ify something that is not <a>?

5 years ago

karelb
Member | 17
+
0
-

Hello,

simple newbie question,

I like how simple is to “ajaxify” <a href>s with <a n:href="signal!" class="ajax">; however, now I want to add on-click action for something that is not <a>. How do I do that easily?

For example, I want to add something like this to a <td> element. <td n:href="signal!" class=ajax> does not work. Enclosing the <td> with <a> does not work either.

What is the simpliest way to achieve this?

Last edited by karelb (2013-12-26 18:45)

5 years ago

Aurielle
Member | 1283
+
0
-

I don't think you can attach href parameter to <td>. In this case you'd have to write your own JS code.

5 years ago

petr.pavel
Backer | 492
+
0
-
<td data-href="{plink signal!}" class="ajax">
$('td.ajax').on('click', function() {
  var url = $(this).data('href');
  // etc.
});