Attach on click event to link in repeat

Kind of a strange one…

I’m trying to attach an on click event to links of a class which are listed out via a repeat. The on click doesn’t work though. It does work if I give a link outside the repeat (see Test Click below) the same class so it’s something to do with the repeat.

Any pointers would be most appreciated.

In document.ready…

     $('.tb_list').on('click', function () {
        alert('click');
     });

 <a class="tb_list" href="#">Test Click</a>
   <div dmx-repeat:repeat_tb_tree="sc_tripbits.data.query">
     <a class="tb_list" href="#">{{title}}</a>
    </div>

Have you tried adding the Browser component on the page and doing an on click browser alert on the link in the repeat?

<div dmx-repeat:repeat_tb_tree="sc_tripbits.data.query">
     <a class="tb_list" dmx-on:click="browser1.alert('the alert text')">{{title}}</a>
    </div>

Ah - should have explained. The reason I’m doing it via the class selector is I’m dragging and dropping the element into another element which then deletes onclick events from the element that’s dropped. Why, I don’t know, but I thought it would be easier to address the class than figure out how to stop the onclick from being stripped out (dmx-on:click is stripped out as well).

Ah, ok. Hopefully someone else has an idea. It’s odd it’s being stripped out.

Hey @Heather_Mann,

I don’t know what the click event action are but I tried a simple alert like you show and it works with a flow->run_Javascript attached in your anchor button.

<div class="col" dmx-repeat:repeattest="srvc_VariationList.data.qr_VariationList">
     <a href="#" class="btn" dmx-text="var_name" dmx-on:click="run({runJS:{function:'itemClicked',outputType:'text'}})">
     </a>
</div>

function itemClicked() {
     alert('click');
}