Closed (fixed)
Project:
Webform
Version:
7.x-3.9
Component:
Miscellaneous
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
9 May 2011 at 20:21 UTC
Updated:
21 Jun 2013 at 11:36 UTC
In Variants » *** » Content the button for adding new content is not showing up. In addition the edit content appears disabled. Can these functions be turned off? I may have done so inadvertently.
Comments
Comment #1
merlinofchaos commentedThese functions cannot be turned off. The buttons can sometimes disappear if something on the page causes javascript to crash before Panels javascript creates the buttons. Check your javascript console and see if there's a javascript error on the page?
Comment #2
kiernan commentedThe JS console led me to the calender field in Webforms. When enabled the buttons did not work. Once I removed the calender fields the buttons came back on.
Comment #3
merlinofchaos commentedYou should move this issue to the module providing the javascript, and provide the actual error. Maybe if we're lucky it'll be an easy fix.
Comment #4
kiernan commentedI have not moved a issue before. Do I just change the Issue settings?
Comment #5
merlinofchaos commentedYes.
Comment #6
kiernan commentedI am moving this from Panels for review. I managed to isolate the problem but due not know how solve the issue for others.
Comment #7
quicksketchCould you describe the error you're getting in the JavaScript console? My guess is Webform doesn't have all the settings it needs to render the calendar correctly. Unfortunately I don't regularly use Panels, I'm not very likely to look into this myself.
Comment #8
kiernan commentedHere is what I got when recreated. I issue is present when in the edit panel UI.
Error: $calendar[0] is undefined
Source File: http://XXXXX/sites/all/modules/webform/js/webform.js?ll3m9y
Line: 21
/**
* JavaScript behaviors for the front-end display of webforms.
*/
(function ($) {
Drupal.behaviors.webform = Drupal.behaviors.webform || {};
Drupal.behaviors.webform.attach = function(context) {
// Calendar datepicker behavior.
Drupal.webform.datepicker(context);
};
Drupal.webform = Drupal.webform || {};
Drupal.webform.datepicker = function(context) {
$('div.webform-datepicker').each(function() {
var $webformDatepicker = $(this);
var $calendar = $webformDatepicker.find('input.webform-calendar');
var startYear = $calendar[0].className.replace(/.*webform-calendar-start-(\d+).*/, '$1');
var endYear = $calendar[0].className.replace(/.*webform-calendar-end-(\d+).*/, '$1');
var firstDay = $calendar[0].className.replace(/.*webform-calendar-day-(\d).*/, '$1');
// Ensure that start comes before end for datepicker.
if (startYear > endYear) {
var greaterYear = startYear;
startYear = endYear;
endYear = greaterYear;
}
// Set up the jQuery datepicker element.
$calendar.datepicker({
dateFormat: 'yy-mm-dd',
yearRange: startYear + ':' + endYear,
firstDay: parseInt(firstDay),
onSelect: function(dateText, inst) {
var date = dateText.split('-');
$webformDatepicker.find('select.year, input.year').val(+date[0]);
$webformDatepicker.find('select.month').val(+date[1]);
$webformDatepicker.find('select.day').val(+date[2]);
},
beforeShow: function(input, inst) {
// Get the select list values.
var year = $webformDatepicker.find('select.year, input.year').val();
var month = $webformDatepicker.find('select.month').val();
var day = $webformDatepicker.find('select.day').val();
// If empty, default to the current year/month/day in the popup.
var today = new Date();
year = year ? year : today.getFullYear();
month = month ? month : today.getMonth() + 1;
day = day ? day : today.getDate();
// Make sure that the default year fits in the available options.
year = (year < startYear || year > endYear) ? startYear : year;
// jQuery UI Datepicker will read the input field and base its date off
// of that, even though in our case the input field is a button.
$(input).val(year + '-' + month + '-' + day);
}
});
// Prevent the calendar button from submitting the form.
$calendar.click(function(event) {
$(this).focus();
event.preventDefault();
});
});
}
})(jQuery);
Comment #9
quicksketchCould you try adding the following?
Right after:
var $calendar = $webformDatepicker.find('input.webform-calendar');
Add this:
If that works I'd be happy to include this change in the next version of Webform.
Comment #10
merlinofchaos commentedCTools is using a similar method to Core in D7 for transmitting ajax and settings during ajax requests, and it actually works (more or less) with wysiwyg.module.
Comment #11
kiernan commentedI added the code and the add content button is there. I added content. The fix look good.
Thanks
Comment #12
quicksketch@merlinofchaos: Yeah the odd thing is this problem would indicate that the JavaScript is all loading fine but something in the markup is wrong. Since the JS executes but it doesn't find the markup it expects. The suggestion I made in #9 essentially is a "bail out if the markup isn't what you expect". So whatever CTools is doing with JS is probably fine, but the markup being pulled in is unexpected.
Comment #13
kiernan commentedComment #15
duntuk commented#9 doesn't work, but this does; put right before the var's:
if(!window.console){ window.console = {log:function(){}}; }so it looks like this
POW!
Comment #16
theodorosploumis#9 works for me too. Thanks!
Comment #17
majdi commented#9 Works fine for me
Comment #18
fonant commented#9 already present in the code, but popup still breaks with
$calendar.datepicker is not a functionWebform 6.x-3.19
Date Popup 6.x-2.9
Disabling console logging as per #15 makes no difference.
Comment #19
fonant commentedArghh! My mistake: I hadn't installed the jQuery UI module.