Skip to content

Commit

Permalink
Initialize tooltips when a new a row is added in a subform
Browse files Browse the repository at this point in the history
  • Loading branch information
okonomiyaki3000 committed Apr 13, 2018
1 parent b5b9d49 commit 948115d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 88 deletions.
80 changes: 0 additions & 80 deletions htaccess.txt

This file was deleted.

10 changes: 8 additions & 2 deletions libraries/cms/html/bootstrap.php
Expand Up @@ -462,7 +462,7 @@ public static function tooltip($selector = '.hasTooltip', $params = array())
$options = JHtml::getJSObject($opt);

// Build the script.
$script = array('$(' . json_encode($selector) . ').tooltip(' . $options . ')');
$script = array('$(container).find(' . json_encode($selector) . ').tooltip(' . $options . ')');

if ($onShow)
{
Expand All @@ -484,8 +484,14 @@ public static function tooltip($selector = '.hasTooltip', $params = array())
$script[] = 'on("hidden.bs.tooltip", ' . $onHidden . ')';
}

$initFunction = 'function initTooltips (event, container) { ' .
'container = container || document;' .
implode('.', $script) . ';' .
'}';

// Attach tooltips to document
JFactory::getDocument()->addScriptDeclaration('jQuery(function($){ ' . implode('.', $script) . '; });');
JFactory::getDocument()
->addScriptDeclaration('jQuery(function($){ initTooltips(); $("body").on("subform-row-add", initTooltips); ' . $initFunction . ' });');

// Set static array
static::$loaded[__METHOD__][$selector] = true;
Expand Down
5 changes: 0 additions & 5 deletions media/system/js/subform-repeatable-uncompressed.js
Expand Up @@ -239,11 +239,6 @@
$row.find('.field-media-wrapper').fieldMedia();
}

// bootstrap tooltips
if($.fn.tooltip){
$row.find('.hasTooltip').tooltip({html: true, container: "body"});
}

// bootstrap based User field
if($.fn.fieldUser){
$row.find('.field-user-wrapper').fieldUser();
Expand Down
3 changes: 2 additions & 1 deletion media/system/js/subform-repeatable.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 948115d

Please sign in to comment.