0

I created a little accessory to insert a row anywhere in a Grid field. This works great with the exception of when the grid has a File field. When I create the row the Add File link does not get handled. I managed to dig through the compressed EE JavaScript code and was able to figure out manually process the Add File link with this.

$.ee_filebrowser.add_trigger

Using this I was able to populate the file image thumbnail and name to match what EE does. Although this seems to work it seems like a really bad idea for future compatibility with EE. The other issue I am having is handling the Remove File link.

So I have a couple of questions:

1) How can I use/call the existing EE JavaScript code to handle the Add File functionality?

2) How can I use/call the existing EE JavaScript code to handle the Remove File functionality?

0

If you're implimenting your file field within an extension/accessory, why not use the File Field Class?

If you instansiate this field as per the docs it should add the required JS to your outputted template automatically (see Creating a file field and Initializing a file browser )

| improve this answer | |
  • The only thing my accessory does is add an icon under the move row icon so that when clicked it inserts a new grid row above the current row. The accessory does this for all grid fields when editing / publishing a channel entry. – Trevor Orr Jun 4 '15 at 16:53
0

I changed my JavaScript so that when the Insert Row icons is clicked I trigger the add row click and then move to the newly created row to the correct location in the table. This allows for the EE JavaScript to handle any custom fields and now File fields work correctly.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.