Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • B bootstrap
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 263
    • Issues 263
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 114
    • Merge requests 114
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Bootstrap
  • bootstrap
  • Merge requests
  • !15674

Add dataBinder support to Tooltip and Popover setContent

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/IDisposable/patch-2 into master Jan 27, 2015
  • Overview 0
  • Commits 10
  • Pipelines 0
  • Changes 3

Created by: IDisposable

Add the ability to set a binder in the Tooltip & Popover options to support data-binding of the created DOM in setContent. This allows having binding expressions in the template that will be applied as the tooltip/popover is created during the show event. This can be used by setting the dataBinder to a function that will apply bindings. Since the DOM elements are not created until the tooltip is shown, the best place for this seems to be set setContent method.

An example of the use of this it for knockout binds, here we create a knockout binding that hooks itself up:

     ko.bindingHandlers.popover = {
         init: function (element, valueAccessor, allBindings, viewModel, bindingContext) {
            var options = $.extend({ disabled: false }, ko.toJS(valueAccessor()));
            ko.utils.domNodeDisposal.addDisposeCallback(element, function () {
                $(element).popover('destroy');
            });
         },
         update: function (element, valueAccessor, allBindings, viewModel, bindingContext) {
            var $element = $(element);
            var options = $.extend({ disabled: false }, ko.toJS(valueAccessor()));
            $element.popover('destroy');
            if (options.disabled)
                return;

            options.dataBinder = function ($tip) {
                ko.cleanNode($tip[0]);
                $tip.applyBindings(viewModel);
            };
            $element.popover(options);
         }
     };
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/IDisposable/patch-2