Get 2024 Templates Mega Bundle!14 Bootstrap, Vue & React Templates + 3 Vector Sets
Get for 99$

Rails Helpers for Vendors


Hello and thank you for this thoughtful template integration into rails 7. I've been through all files and rails help documentation but I do not understand how to use the rails helper in controller or view for datatables?

JS and CSS are loading correctly for datatables.

Examples from documentation:

helpers.addVendor('datatables')
Does this go in the controller?

addVendor(vendor)
Does this go at the bottom of the view template?

I am trying to use the following code in my view template

table id="kt_datatable_dom_positioning"


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (3)


Hi,

In the Rails controller, you can call any helper functions from /app/helpers/* files using helpers object. Eg. helpers.addVendor('datatables')

The addVendor function is defined in /app/helpers/application_helper.rb

The vendors' entries will be printed in the /app/views/layout/master.html.erb. JS files at the bottom and CSS in the head.


getVendors("css")
getVendors("js")


Thanks



Thanks for the response. I was able to get it working after adding the DataTable script at the bottom of the master.html.erb


<script>
$("#kt_datatable_dom_positioning").DataTable({
"language": {
"lengthMenu": "Show _MENU_",
},
"dom":
"<"row"" +
"<"col-sm-6 d-flex align-items-center justify-content-start"l>" +
"<"col-sm-6 d-flex align-items-center justify-content-end"f>" +
">" +

"<"table-responsive"tr>" +

"<"row"" +
"<"col-sm-12 col-md-5 d-flex align-items-center justify-content-md-start"i>" +
"<"col-sm-12 col-md-7 d-flex align-items-center justify-content-md-end"p>" +
">"
})
</script>



Glad you solved it. Feel free to let us know if you have any issues.

Thanks


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(