• WP-AppKit themes are based on Javascript.
  • All app themes have a functions.js file which is the entry point for your theme’s Javascript (e.g. event bindings, DOM manipulation, dialog with app core …).
  • The path to functions.js is: wp-content/themes-wp-appkit/[your-theme]/js/functions.js.
  • Inserting Javascript directly in templates (e.g. single.html) should be done with caution. Simple code is fine (like string concatenations, conditional statements, component content retrieval…), all within UnderscoreJS template engine tags <% … %>, but DOM manipulation has to be avoided.
define(['jquery','core/theme-app'],function($,App){

      //Launch app content refresh when clicking your refresh button :
      $('#my-refresh-button').click(function(e){
            e.preventDefault();
            App.refresh(function(){
                  $('#my-feedback').html('Content updated successfully :)').show();
            });
      });

});
You may also include Javascript libraries using RequireJS dependency management (the first “define” line of the above example). More on that here.

Happy coding!

Published by Mathieu on July 4, 2014

Freelance Senior Web Developer, WordPress since 2009, JS/Backbone since 2012, Custom Back-End devs, WebApps and Plugins for clients and the community.

Leave a Reply

Your email address will not be published. Required fields are marked *

Having questions?

FAQ | Tutorials | Documentation

Or

Contact Us