I’m trying to update one of my add-ons for fluid field compatibility, but I can’t seem to get the FluidField.on event to fire. Here’s my code that shows how I’ve successfully enabled Grid support, and how I’m trying to do the same for fluid fields.
$(document).ready(function(){
if(Grid !== undefined)
{
Grid.bind('event_helper', 'display', function(cell)
{
EE.cp.datePicker.bind(($('input[rel="date-picker"]', cell)));
});
}
if(FluidField !== undefined)
{
FluidField.on('event_helper', 'add', function(row)
{
EE.cp.datePicker.bind(($('input[rel="date-picker"]', row)));
});
}
});
Removing the undefined check doesn’t help, and inserting a test alert() call in there never fires either.
Any ideas.
The add
event for Fluid Fields triggers when a new field instance is added to the fluid field in the publish form, as opposed to Grid’s display
event which also triggers on the initial render of the field. Thus, your date picker should bind when an event_helper
field is added to the Fluid Field in the publish page. If it isn’t firing in that case I’d have you refresh the JS files from the latest developer preview build just to make sure there aren’t any stale JS files.
Hmm, I’ve emptied my caches and tried over the course of a few days. So I’m pretty sure my install’s javascript libraries are up-to-date.
The events are attached correctly on page load for existing fields within the fluid field. It’s just the new fields created when adding a new row that are not working.
Is my code correct?
Yes, your code does look right. In fact, it looks nearly identical to the JS we use in the date fieldtype which I can confirm works:
if (FluidField !== undefined)
{
FluidField.on('date', 'add', function(field)
{
EE.cp.datePicker.bind($('input[rel="date-picker"]', field));
});
}
Would it be possible to get a copy of your add-on so I can take a look and see why the JS event isn’t triggering?
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.