Module LiveTree::LiveTreeHelper
In: live_tree.rb

Methods

Public Instance methods

Returns data in JSON notation appropriate for use with the :initial_data parameter of construct_live_tree_function .

Arguments:

  • item - Root item of the data.
  • options - Same options as LiveTree.get_live_tree_data, as well as:
    • :depth - How many level deep to recurse (default is nil, which means to recurse to the ends of all branches).

Returns JavaScript code that constructs a JavaScript LiveTree object.

Arguments:

  • name - name of the tree
  • options - most of these options are passed to the JavaScript LiveTree object as-is, but their names are converted to camelcase-with-lowercase-first-letter (e.g. :on_click_item becomes onClickItem). See LiveTreeClient for details details about those options. In addition, the following may be specified:
    • :id - HTML ID to give the tree’s top HTML element (default is the tree’s name).
    • :data_action - Action used by the tree to read data (default is "#{name}_live_tree_data").
    • :data_controller - Controller used by the tree to read data (default is the current controller).
    • :initial_data_root - Root item to construct initial tree data (optional, but you almost certainly want to include this).
    • :initial_data_whole_tree - Specifies whether the entire tree should be sent in the initial data, in which case the client will never have to contact the server for more data (default false, only used if :initial_data_root is specified).
    • :initial_data_options - Specifies options for constructing the initial data. See construct_live_tree_data for details. If you used LiveTree::ClassMethods.live_tree to setup your controller, you don’t need to specify this (the same values passed to live_tree are used). (default {}, only used if :initial_data_root).

Embeds a LiveTree at the current location in the document.

Arguments:

  • name - name of the tree
  • options - may contain any of the options documented in construct_live_tree_function, as well as:
    • :js_variable_name - JavaScript variable name to assign the JavaScript LiveTree object to (optional).

If :js_variable_name is not specified, the tree is assigned to a variable with the name of the tree converted to camelcase with a lowercase first letter (e.g. if the tree is named family_tree, it will be assigned to familyTree).

[Validate]