Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call the popover init function when creating new subform rows. #20222

Merged
merged 2 commits into from
Apr 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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