1

I'm using the createElementsSelectorModal to access certain element types as described by Brandon here

With this implementation, how would I clear out "disabledElementIds"? So that if an Entry is added and then removed I can tell the Modal it should be selectable again.

Thanks!

3

Elements can be manually enabled/disabled from the modal after it has been initialized using the following methods:

myModal.elementIndex.enableElementsById(elementIds);

and

myModal.elementIndex.disableElementsById(elementIds);

Both functions accept a number (single element ID) or an array of numbers (multiple element IDs).

|improve this answer|||||
  • Thanks Brandon, I appreciate the quick response. I'm not 100% sure I'm using this correctly. If I didn't want the modal to pop up automatically and I wanted to reuse the modal if my Field Type plugin is added to the page multiple times, how would I go about this? – Peter Tell Jul 11 '14 at 20:47
  • Just don’t create the modal in your JS until it’s actually needed. – Brandon Kelly Jul 11 '14 at 21:30
  • Fair enough, that is kind of what I'm doing. I wrapped a function around creating the modal and call it on a click event, passing in the parameters I need. Thanks again! – Peter Tell Jul 11 '14 at 21:33
1

Well, this probably wasn't the best way to go about it, but I solved this by manually defining what is un-selectable:

var unSelectable = [1,2,3]

And then I keep track of the array as things happen in the DOM and pop items in and out. Then, I pass them to the function I use to call Craft.createElementSelectorModal() setting disabledElementIds manually:

disabledElementIds: unSelectable,
|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.