Skip to content

Latest commit

 

History

History
24 lines (17 loc) · 753 Bytes

idempotency.md

File metadata and controls

24 lines (17 loc) · 753 Bytes

Idempotency

You can call $.onmount() as much as you like. This will skip any behavior initialization for DOM nodes that have already been initialized. This is done to account for any new elements that may appear in your DOM.

// add more content
$('#content').append(...)

$.onmount()

This allows you to set up polling checkpoints to trigger new behaviors on certain events. Great for events such as Bootstrap events or Turbolinks load.

Also, when used with jQuery, onmount can be passed as an event handler, eg, $(onmount).

$(document)
  .on('ready show.bs closed.bs load page:change', $.onmount)