JavaScript Angular how to fire a callback function after DOM elements are updated for each digest angularfire callback

I want to make an angular body-scroll only table. To make it simpler, I created two tables, one of which only has the headers, and the other table is for the body. The body table is wrapped into a div with max-height:300px.

The two tables are aligned when the body table does not have a scroll bar, but disaligned when the body table has a scroll bar. What I tried is to watch the clientWidth of the body table, whenever it changes, apply the new client width to the header table so that those two tables are always aligned.

In the controller, I have

$scope.$watch(function() {
    var tbody = $element.find('tbody.sku-table-body');
    return tbody[0].clientWidth;

}, function(newClientWidth) {
    console.log(newClientWidth);
    $scope.tableClientWidth = newClientWidth;
});

And then in the header table, add ng-style="{'width': tableClientWidth}"

The issues is the watch callback is called before angular update the DOM. For example, if initially there are only 10 rows in the table, and there is no scroll bar. The two tables are aligned. Then I clicked a button to load 10 more records, the scroll bar on the body table appears, but the newClientWidth is still the old client width since the watch callback is called before angular update the body table. The two tables are disaligned now.

What I need is fire a function to update the header table width whenever angular finishes updating the DOM for each digest cycle. The function may be something like

function(){ var clientWidth= $('.body-table')[0].clientWidth; $('.header-table').width(clientWidth); }

I have seen $evalAsync and $timeout, and looks like they are one time execution. What I want is fire a function EACH time AFTER angular finishes updating the DOM.

Any comments would be greatly appreciated

Answer:1

I understand there are other pages on this but I am trying to get my own working and I do not know why it is not working. I am new to node.js. for (var index in output) { if (opt.options....

I understand there are other pages on this but I am trying to get my own working and I do not know why it is not working. I am new to node.js. for (var index in output) { if (opt.options....

  1. removing empty strings from a list in python
  2. removing empty strings from list
  3. remove empty strings from array javascript
  4. remove empty strings from list c#
  5. remove empty strings from array
  6. remove empty strings from array ruby
  7. remove empty strings from array php
  8. remove empty strings from array java
  9. remove empty strings from array js
  10. remove empty strings from list java
  11. remove empty strings from array c#
  12. remove empty strings from array python
  13. remove empty strings from list r
  14. remove empty strings from vector r
  15. remove empty strings from object javascript
  16. remove empty strings python
  17. remove empty strings r
  18. remove empty strings from list javascript
  19. remove empty strings
  20. remove empty strings from array swift

Does anyone know in which order the jQuery sortable events are being triggered? I'm asking this because I had a problem with stop and update. It made more sense to me that update event would come ...

Does anyone know in which order the jQuery sortable events are being triggered? I'm asking this because I had a problem with stop and update. It made more sense to me that update event would come ...

  1. jquery sortable order number
  2. jquery sortable order
  3. jquery sortable order save
  4. jquery sortable reorder list
  5. jquery sortable reorder array
  6. jquery sortable get order
  7. jquery sortable save order in database
  8. jquery sortable update order
  9. jquery sortable get order of elements
  10. jquery sortable set order
  11. jquery sortable save order in database mvc
  12. jquery sortable get order of items
  13. jquery sortable change order
  14. jquery ui sortable order
  15. jquery sortable change order programmatically
  16. jquery sortable save order mysql
  17. jquery sortable post order
  18. jquery sortable sort order
  19. jquery sortable event order
  20. jquery ui sortable order number

N.B. I'm aware that I add ids and combine these in a selector e.g. "#myDiv1,#myDiv2" so please refrain from suggesting this as it does not relate to my question. Is there a way to 'chain' the vars ...

N.B. I'm aware that I add ids and combine these in a selector e.g. "#myDiv1,#myDiv2" so please refrain from suggesting this as it does not relate to my question. Is there a way to 'chain' the vars ...

  1. jquery on click
  2. jquery on change
  3. jquery onload
  4. jquery on hover
  5. jquery on page load
  6. jquery on ready
  7. jquery on submit
  8. jquery on select change
  9. jquery onclick function
  10. jquery on scroll
  11. jquery on focus
  12. jquery on keyup
  13. jquery on multiple events
  14. jquery one
  15. jquery on button click
  16. jquery on resize
  17. jquery on checkbox change
  18. jquery on input
  19. jquery once
  20. jquery on input change

I'm relatively new to JavaScript and I'm working on what should be a simple project. I'm stuck though and I'd love some opinions on ways to get a solution. I have a short products array like: var ...

I'm relatively new to JavaScript and I'm working on what should be a simple project. I'm stuck though and I'd love some opinions on ways to get a solution. I have a short products array like: var ...

  1. need of index number
  2. why do we need index number
  3. i need postal index number
  4. i need my index number