We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Trouble getting FluidField.on events to work

Developer Preview

Derek Hogue's avatar
Derek Hogue
316 posts
7 years ago
Derek Hogue's avatar Derek Hogue

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.

       
Seth Barber's avatar
Seth Barber
172 posts
7 years ago
Seth Barber's avatar Seth Barber

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.

       
Derek Hogue's avatar
Derek Hogue
316 posts
7 years ago
Derek Hogue's avatar Derek Hogue

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?

       
Seth Barber's avatar
Seth Barber
172 posts
7 years ago
Seth Barber's avatar Seth Barber

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?

       
Derek Hogue's avatar
Derek Hogue
316 posts
7 years ago
Derek Hogue's avatar Derek Hogue

Well, now it’s working and I didn’t change a damn thing! I’m going to slowly back away from the computer now and hope nothing weird happens.

Thanks for the help!

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.