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

Can't Get the Sidebar Delete Icon working

Development and Programming

TJ Draper's avatar
TJ Draper
222 posts
about 9 years ago
TJ Draper's avatar TJ Draper

I feel like I’m missing something here. Here’s what I’ve got:

// Create the sidebar
$sidebar = ee('CP/Sidebar')->make();

// Add the heading
$header = $sidebar->addHeader(lang('locations'));

// Add list
$list = $header->addFolderList('locations_list');

// Set up the remove url
$list->withRemoveUrl(ee('CP/URL')->make(
 'addons/settings/treasury/removeLocation/'
));

// Get locations
$locations = // stuff happens here to get locations

// Loop through the locations
foreach ($locations as $location) {
 $item = $list->addItem($location->name, ee('CP/URL')->make(
  "addons/settings/treasury/showLocation/{$location->id}"
 ));

 // Set the item identification
 $item->identifiedBy($location->id);

 // Set up edit url
 $item->withEditurl(ee('CP/URL')->make(
  "addons/settings/treasury/editLocation/{$location->id}"
 ));

 // Set up the remove confirmation message
 $item->withRemoveConfirmation('Deleting this location will not delete the files associated with this location.');
}

That should allow the delete button on items to work as far as I can tell from the documentation. However, the confirmation dialog looks like the image attached to this post. No custom message and does not list the item I am trying to delete. Not encouraging.

Clicking confirm and remove takes me to the method/url I specified in the code above, but the id key in the post data is empty.

Inspecting the delete icon link shows that there is a data-confirm attribute with my custom message, and a data-id attribute with the correct id for the items. So it seems like this thing ought to be working.

Help?

       
TJ Draper's avatar
TJ Draper
222 posts
about 9 years ago
TJ Draper's avatar TJ Draper

Bump. Anyone at EL have any thoughts on this?

       
Pascal Kriete's avatar
Pascal Kriete
2,589 posts
about 9 years ago
Pascal Kriete's avatar Pascal Kriete

Yikes, this is indeed a little messy. The docs also had me assuming that it would just work, but it looks like we have some js in the places where we use it. Looks we missed a refactor during 3.0 - I’m kinda surprised it hasn’t come up elsewhere. I’ll fix that up for you and make it automatic.

For now, this is the snippet:

$(document).ready(function () {
 $('.sidebar .folder-list .remove a.m-link').click(function (e) {
  var modalIs = '.' + $(this).attr('rel');

  $(modalIs + " .checklist").html(''); // Reset it
  $(modalIs + " .checklist").append('<li>' + $(this).data('confirm') + '</li>');
  $(modalIs + " input[name='dir_id']").val($(this).data('dir_id'));

  e.preventDefault();
 })
});

Just replace dir_id and you’re golden. Thanks for catching it!

       
TJ Draper's avatar
TJ Draper
222 posts
about 9 years ago
TJ Draper's avatar TJ Draper

Got it. That works perfectly. Thanks!

       

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.