wet-boew / wet-boew-styleguide

A style guide for the Web Experience Toolkit.
http://wet-boew.github.io/wet-boew-styleguide/index-en.html
36 stars 32 forks source link

How do you manually initialize the table plug-in? #122

Closed RitchieD closed 10 years ago

RitchieD commented 10 years ago

How do you manually initialize the table plug-in?

I have a page that uses ajax to return a result table. The main page does not have a table. So I need to manually initialize the table.

Documentation is unclear. http://wet-boew.github.io/v4.0-ci/docs/ref/tables/tables-en.html

The following fails to find $elm $elm.trigger( “wb-init.wb-inview” );

The following line does nothing. $(document).trigger("wb-init.wb-tables");

This line doesn’t find “dataTable()”. $(document).ready(function () { $('#mytableid').dataTable(); });

WET v4.0

pjackson28 commented 10 years ago

@RitchieD You would need to replace $elm with a jQuery object reference to the table. So if the id on the table is "mytable", then you could use $( "#mytable" ).( "wb-init.wb-tables" );. You could also cache the reference to $elm (e.g., $elm = $( "#mytable" );) and then use the line of code from the documentation.

nschonni commented 10 years ago

Looks like the document is using the wrong event (for inview not table), but this should probably be discussed in core not the styleguide.

pjackson28 commented 10 years ago

@nschonni Thanks for catching the wb-inview (just copied and pasted). I've updated my response. And yes, this discussion would be more appropriate in wet-boew/wet-boew.

RitchieD commented 10 years ago

Thanks. Here is my final working code:

<script type='text/javascript'>
    $elm = $('#tableCases')
    $elm.trigger( 'wb-init.wb-tables' ); 
</script>