Home > Enterprise >  How can I add event listener to span added by DTColumnBuilder?
How can I add event listener to span added by DTColumnBuilder?

Time:07-21

I am trying to add event onclick to a span added by DTColumnBuilder.

                DTColumnBuilder
                    .newColumn('Invoice')
                    .withTitle('<span >Invoice</span>')
                    .withOption('visible', true)
                    .renderWith(function (data, type, full) {
                        return `<span style="color: #337AB7;cursor:pointer">Download</span>`;
                    }),

when I try too add onclick (<span onclick="test()" .../span>) I am getting an error saying that test() is not defined even though I have defined test.

CodePudding user response:

Use below code

<span ng-click="test()" .../span>

If test function is available in the current scope then use this.test() . according to the function scope do the function call

CodePudding user response:

you just use ng-click instead of onclick

  • Related