Hi there, I 've just gotten my directive to pull in a template to append to its element like this:# CoffeeScript.directive 'dashboardTable', ->controller: lineItemIndexCtrltemplateUrl: "<%= asset_path('angular/templates/line_items/dashboard_rows.html') %>"(scope, element, attrs) ->element.parent('table#line_items').dataTable()console.log 'Just to make sure this is run'# HTML<table id="line_items"><tbody dashboard-table></tbody></table>I am also using a jQuery Plugin called DataTables. The general usage of it is like this: $('table#some_id').dataTable(). You can pass in the JSON data into the dataTable() call to supply the table data OR you can have the data already on the page and it will do the rest.. I am doing the latter, having the rows already on the HTML page.But the problem is that I have to call the dataTable() on the table#line_items AFTER DOM ready. My directive above calls the dataTable() method BEFORE the template is appended to the directive's element. Is there a way that I can call functions AFTER the append?Thank you for your help!--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To view this discussion on the web visit https://groups.google.com/d/msg/angular/-/Nds7-o0tQf8J.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/angular?hl=en.
--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular?hl=en.
You could have a directive that checks if the last element had finished what it need to do.
Special properties are exposed on the local scope of each template instance, including:
$index – {number} – iterator offset of the repeated element (0..length-1)$first – {boolean} – true if the repeated element is first in the iterator.$middle – {boolean} – true if the repeated element is between the first and last in the iterator.$last – {boolean} – true if the repeated element is last in the iterator.Thanks John,I think there was some discussion about this in the past - my understanding is that what you've done will almost always work, but cannot be guaranteed, and so has been explicitly left out so as not to be relied upon. While Angular can know when it has finished calling all of the callbacks it has registered for manipulating the DOM and can broadcast on it (as you have done), there's no way to know that those functions themselves have completed their DOM manipulation as some of those things could be done asynchronously.
Hi,Yes, what you said is true and i am supposing you mean done render as element.ready.in the jsfiddle, i am checking if the element is ready (http://api.jquery.com/ready/) if DOM is not yet created,the problem is this, the fiddle is checking on dom ready, if the data arrived after dom ready then the datatable won't be consumed.thus i updated a bit.http://jsfiddle.net/roychoo/cp6u6/12/ , to simulate that data comes after, you can click on the load data
RegardsRoy
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.