Skip to content

Commit

Permalink
Call the popover init function when creating new subform rows. (#20222)
Browse files Browse the repository at this point in the history
* Call the popover init function when creating new subform rows.

* Update teh popover test
  • Loading branch information
okonomiyaki3000 authored and Michael Babker committed Apr 29, 2018
1 parent 49e681f commit c12c682
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion libraries/cms/html/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,13 @@ public static function popover($selector = '.hasPopover', $params = array())

$options = JHtml::getJSObject($opt);

$initFunction = 'function initPopovers (event, container) { ' .
'$(container || document).find(' . json_encode($selector) . ').popover(' . $options . ');' .
'}';

// Attach the popover to the document
JFactory::getDocument()->addScriptDeclaration(
'jQuery(function($){ $(' . json_encode($selector) . ').popover(' . $options . '); });'
'jQuery(function($){ initPopovers(); $("body").on("subform-row-add", initPopovers); ' . $initFunction . ' });'
);

static::$loaded[__METHOD__][$selector] = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ public function testPopover()

$this->assertEquals(
$document->_script['text/javascript'],
'jQuery(function($){ $(".hasPopover").popover({"html": true,"trigger": "hover focus","container": "body"}); });',
'jQuery(function($){ initPopovers(); $("body").on("subform-row-add", initPopovers); function initPopovers (event, container) { $(container || document).find(".hasPopover").popover({"html": true,"trigger": "hover focus","container": "body"});} });',
'Verify that the popover script is initialised'
);
}
Expand Down

0 comments on commit c12c682

Please sign in to comment.