Action Button loosing it's binding on browser resizing, Please Help
See original GitHub issueHi @l-lin
I followed the example from angular-datatables advance example Bind Angular Directive and used it together with the Responsive plugin. but it’s loosing action filed’s Binding.
I have follow all comments from the issue https://github.com/l-lin/angular-datatables/issues/324 but no luck,
it’s working fine in full screen.
Here is the Code:
‘use strict’; angular.module(‘showcase.withResponsive’, [‘datatables’]) .controller(‘WithResponsiveCtrl’, WithResponsiveCtrl);
function WithResponsiveCtrl($scope, $compile,DTOptionsBuilder, DTColumnBuilder) { var edit = function() { alert(‘edit!’); };
var deleteRow = function() {
alert('delte!');
};
var actionsHtml = function (data, type, full, meta) {
return '<button class="btn btn-warning" ng-click="edit()">' +
' <i class="fa fa-edit"></i>' +
'</button> ' +
'<button class="btn btn-danger" ng-click="deleteRow()">' +
' <i class="fa fa-trash-o"></i>' +
'</button>';
};
var createdRow = function (row, data, dataIndex) {
$compile(angular.element(row).contents())($scope);
};
$scope.edit = edit;
$scope.deleteRow = deleteRow;
$scope.message = '';
$scope.dtInstance = {};
$scope.dtOptions = DTOptionsBuilder.fromSource('http://127.0.0.1:1771/data.json')
.withPaginationType('full_numbers')
.withOption('createdRow', createdRow)
.withOption('responsive', true);
$scope.dtColumns = [
DTColumnBuilder.newColumn('id').withTitle('ID'),
DTColumnBuilder.newColumn('firstName').withTitle('First name'),
DTColumnBuilder.newColumn('lastName').withTitle('Last name'),
DTColumnBuilder.newColumn(null).withTitle('Actions').notSortable().renderWith(actionsHtml)
];
}
Table HTML
<table datatable="" dt-options="dtOptions" dt-columns="dtColumns" dt-instance="dtInstance" class="row-border hover" width="100%"></table>
Issue Analytics
- State:
- Created 8 years ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Jquery - Click event doesn't work after resized - Stack Overflow
When you resize the screen you are removing the elements and re-adding them, thus losing the binding (on removal). With the $(document).on...
Read more >Handling Events :: Eloquent JavaScript
The window binding refers to a built-in object provided by the browser. ... during resizing, as long as the button is held we...
Read more >A Complete Guide to Links and Buttons - CSS-Tricks
Our complete guide to links, buttons, and button-like inputs in HTML, CSS, and JavaScript.
Read more >Button UI Not Working with The new Input system - Unity Forum
I put the PlayerInput on a separate GameObject from the EventSystem and the rest, then set the binding of the mouse left and...
Read more >EventTarget.addEventListener() - Web APIs | MDN
This creates an options object with a getter function for the passive property; the getter sets a flag, passiveSupported , to true if...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hello, just to share an option to bind a directive in child rows that worked for me.
If you check the dataTables.responsive.js, Responsive object has a static object called ina property defaults with the following code:
So, in the controller you must copy the code above and simply turn that into a function:
And now we set the responsive option with our new function:
what about the idea of compiling the content of the child after showing it ?
something like this :