Sha256: eef22dc6e7527d4cd47372aa8e289af8b742baafe64507cf6c83c0000bbb9976

Contents?: true

Size: 1.11 KB

Versions: 8

Compression:

Stored size: 1.11 KB

Contents

// The ready function sets up a callback to run on each page load.
//
//     Trestle.ready(function() {
//       ...
//     });
//
Trestle.ready = function(callback) {
  $(Trestle).on('load', callback);
};

// The init function sets up a callback to run on each page load, as well as when elements are added to the page
// dynamically (e.g. via a modal). It is used to initialize dynamic elements such as date pickers, although it is
// preferable if they can be set up using event delegation on the document element.
//
// The callback is triggered with the applicable root/container element as the second argument.
//
//     Trestle.init(function(e, root) {
//       $(root).find('...');
//     });
//
Trestle.init = function(callback) {
  $(Trestle).on('init', callback);
};

// Initialize all elements within the document on page load.
Trestle.ready(function() {
  $(Trestle).trigger('init', document);
});

// Trigger the page load events.
if (Trestle.turbolinks) {
  $(document).on('turbolinks:load', function() {
    $(Trestle).trigger("load");
  });
} else {
  $(document).ready(function() {
    $(Trestle).trigger("load");
  });
}

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
trestle-0.8.13 app/assets/javascripts/trestle/core/_events.js
trestle-0.8.12 app/assets/javascripts/trestle/core/_events.js
trestle-0.8.11 app/assets/javascripts/trestle/core/_events.js
trestle-0.8.10 app/assets/javascripts/trestle/core/_events.js
trestle-0.8.9 app/assets/javascripts/trestle/core/_events.js
trestle-0.8.8 app/assets/javascripts/trestle/core/_events.js
trestle-0.8.7 app/assets/javascripts/trestle/core/_events.js
trestle-0.8.6 app/assets/javascripts/trestle/core/_events.js