0
<!--Required scripts.-->
<ltng:require styles="{!join(',',$Resource.FrameworkBase + '/css/salesforce-lightning-design-system.css',
                            $Resource.FrameworkBase + '/css/datatablecss/dataTables.bootstrap.css',
                            $Resource.FrameworkBase + '/css/datatablecss/font-awesome.css',
                            $Resource.FrameworkBase + '/css/datatablecss/dataTables.fontAwesome.css')}"
              scripts="{!join(',',$Resource.FrameworkBase + '/js/jquery-3.2.1.min.js',
                            $Resource.FrameworkBase +  '/js/datatablejs/jquery.dataTables.min.js',
                            $Resource.FrameworkBase + '/js/datatablejs/dataTables.bootstrap.js',
                            $Resource.FrameworkBase + '/js/datatables-natural-sort.js',
                            $Resource.FrameworkBase + '/js/dataTableFilter_CF.js',
                            $Resource.FrameworkBase +  '/js/absolute.js')}"
              afterScriptsLoaded="{!c.createDatatableController}" />

I have a filter button created dynamically, and there I am adding attributes using jquery .attr.

          jQuery("document").ready(function(){

                // Other code
                $(objFilterButton).attr('class', 'btn btn-default btn-lightning');
                $(objFilterButton).attr('onClick', 'showFilter(event)');
          });

The class gets added but, I cannot see the onClick event getting added on the dom. Is this a limitation in lightning?

enter image description here

1 Answer 1

1

Yes, this is a limitation of the Lightning framework. Use $(elements).on(eventName, handlerRef) instead. Note that you should not try to use the old onevent style attributes anyways.

1
  • Yes this works :$("#idFromElement").on("click", function() {}) Commented Nov 22, 2019 at 13:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .