View is loaded in a modal
Complete View is rendered successful
also Calendar Input Field and Button are rendered
Click on Button should show calendar popup for select a date
Click on Button doesn't show calendar popup
no select possible
Joomla! 3.7.4 and Joomla! 3.7.5
successful worked on Joomla! 3.6.5 before update to Joomla! 3.7.x
Labels |
Added:
?
|
Category | ⇒ | JavaScript |
Status | New | ⇒ | Information Required |
it's a custom component, not public available.
it's in frontend
no enhancing extensions installed, only Joomla! calendar is used.
like described before we had no problems at all until Joomla! 3.6.5, but after Update to 3.7.x we recognized that the Popup doesn't appear after click on calendar button.
yesterday I've tried to init calendar setup manually and the popup appears, but it doesn't write back the selected date. so maybe it's a similiar problem to #15972 (?)
can you share you snippet that you use to init the calendar?
Is it a form or plain html?
<script>
jQuery(document).ready(function($) {
Calendar.setup({
// Id of the input field
inputField: '<?php echo $field->id; ?>',
// Format of the input field
// ifFormat: '<?php //echo $field->format; ?>//',
// Trigger for the calendar (button ID)
// button: '<?php //echo $field->id; ?>//_img',
// Alignment (defaults to "Bl")
// align: 'Tl',
singleClick : true,
firstDay: '<?php echo JFactory::getLanguage()->getFirstDay(); ?>'
});
});
</script>
I've used this script for init the calendar (again) and popup appears, but selected date wasn't inserted, but field got blank (before the rendered page correctly display a pre-loaded date from database)
There was some discussion about this in this issue tracker
e.g.
#15574
#15251
you need to use
JoomlaCalendar.init(someDOMElement);
also input TAG descedants of someDOMElement will be initialized as calendars
you need something like (test and make any correction needed)
<script>
jQuery(document).ready(function($) {
var input = document.getElementById('<?php echo $field->id; ?>';
var inputParent = input.parentNode; // or input.parentNode.parentNode
JoomlaCalendar.init(inputParentContainer);
});
</script>
(for more, since you are developer study)
/media/system/js/fields/calendar.js
Also to be able to pass configuration to the calendar you need to add
data-*
data-show-time="1"
attributes to the button-tag after the input-tag
see here:
/layouts/joomla/form/field/calendar.php
Now if you did not need to call calendar JS in custom code,
and you only needed calendar on page load, then you could have used Joomla API
...
$attribs['todayBtn'] = 1;
$attribs['weekNumbers'] = 1;
$attribs['showTime'] = 1;
echo JHTML::_('calendar', $date, $fieldname, $elementid, $date_time_format, $attribs);
...
in which case nothing would have broken as JHTML::_('calendar'...) is compatible to legacy calls of it
jQuery(document).ready(function($) {
...
indeed your example above, shows that you are setting up the calendar on document ready
-- so you had no reason not to use the API , and avoid these problems
There are developers using calendar JS directly (me included) but we have updated our code for J3.7.x
Also in all cases of using it on document ready, it is best to use API
instead of calling it directly
This is not a bug , this can be closed,
for more you may post in developers forums
but you do not need to, just study the above code examples and the above mentioned files
Status | Information Required | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2017-08-29 04:39:40 |
Closed_By | ⇒ | joomla-cms-bot |
Closed_By | joomla-cms-bot | ⇒ | franz-wohlkoenig |
Set to "closed" on behalf of @franz-wohlkoenig by The JTracker Application at issues.joomla.org/joomla-cms/17738
closed as stated above.
thank you for your help!
first of all, there are some hints, which helped me to find a solution for that problem. but in my opinion there is a bug since version 3.7.x, because I've not changed parts of that code since upgrading and I don't think that is necessary. In other parts of my implementation the calendar selection works well.
my script above (in my comment before) was just one of the last trial to fix that bug for my view, but it doesn't help like I mentioned (it only shows the popup). now I describe the solution I found with your help (thank you again for quick responses):
...
<!-- add tab set for section licence-->
<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'licence', JText::_('COM_FACPMANAGEMENT_USER_ACCOUNT_LICENCE', true)); ?>
<?php
foreach ($fieldSetLicence as $field) : ?>
<div class="control-group">
<div class="control-label">
<?php echo
$field->label; // will render field names
?>
</div>
<div class="controls <?php if(strtolower($field->type) == 'textarea'): echo strtolower($field->type); endif;?>">
<?php
echo $field->input; // will render all input fields
// start of workaround after upgrading to Joomla! 3.7.x
if($field->type == "Calendar") { // only init calendar if it's needed
JFactory::getDocument()->addScriptDeclaration("
jQuery(document).ready(function (){
var input = document.getElementById('".$field->id."');
var inputParent = input.parentNode;
JoomlaCalendar.init(inputParent);
});");
}
// end of workaround
?>
</div>
</div>
<?php
endforeach;
?>
<?php echo JHtml::_('bootstrap.endTab'); ?>
...
my fault was that I've forgot to mention that I'm also using bootstrap tabs for my details view. The View Fields are definied in xml and will be loaded by the view. (because of critical data I've to hide some other fields)
now a click on the calendar buttons works again, previously without this workaround only the input field and the button was rendered and no selection appears.
maybe it's helpful, if anyone find a problem of my described implementation I'm looking forward for improvement suggestions.
have a nice day!
Kind Regards
Can you be more specific , which view ? of which component ?
frontend , backend ? both of them ?
any calendar enhancing extensions installed ? are they updated to latest version ?