Answers.Body: <p>Elements can be manually enabled/disabled from the modal after it has been initialized using the following methods:</p>
  
  <pre><code>myModal.elementIndex.enableElementsById(elementIds);
  </code></pre>
  
  <p>and</p>
  
  <pre><code>myModal.elementIndex.disableElementsById(elementIds);
  </code></pre>
  
  <p>Both functions accept a number (single element ID) or an array of numbers (multiple element IDs).</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-11T20:47:40.127Z
Answers.Text: 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?
Answers.UserDisplayName: Peter Tell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-11T21:30:59.347Z
Answers.Text: Just don’t create the modal in your JS until it’s actually needed.
Answers.UserDisplayName: Brandon Kelly
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-11T21:33:07.047Z
Answers.Text: 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!
Answers.UserDisplayName: Peter Tell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-11T19:54:57.990Z
Answers.LastActivityDate: 2014-07-11T19:54:57.990Z
Answers.UserDisplayName: Brandon Kelly
Answers.Body: <p>Well, this probably wasn't the best way to go about it, but I solved this by manually defining what is un-selectable:</p>
  
  <pre><code>var unSelectable = [1,2,3]
  </code></pre>
  
  <p>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:</p>
  
  <pre><code>disabledElementIds: unSelectable,
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-11T21:30:31.420Z
Answers.LastActivityDate: 2014-07-11T21:30:31.420Z
Answers.UserDisplayName: Peter Tell
Body: <p>I'm using the createElementsSelectorModal to access certain element types as described by Brandon <a href="https://craftcms.stackexchange.com/questions/895/is-it-possible-to-use-the-elementtype-modal-ui-for-a-custom-field-type-plugin">here</a></p>
  
  <p>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. </p>
  
  <p>Thanks!</p>
  
Tags: <plugin-development>
Title: How would I change "disabledElementIds" when using createElementSelectorModal()?
ThreadText: # How would I change "disabledElementIds" when using createElementSelectorModal()?
  
  (Asked by: username_0 on 2014-07-11)
  
  I'm using the createElementsSelectorModal to access certain element types as described by username_1 [here](https://craftcms.stackexchange.com/questions/895/is-it-possible-to-use-the-elementtype-modal-ui-for-a-custom-field-type-plugin)
  
  With this implementation, how would I clear out "disabledElementIds"? So that if an Entry is added and then removed I can username_0 the Modal it should be selectable again.
  
  Thanks!
  
  **Tags:** plugin-development
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2014-07-11. Score: 3 | Accepted answer
  
  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).
  
  > **Comments:**
  > **username_0**: Thanks username_1, 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?  
  > **username_1**: Just don’t create the modal in your JS until it’s actually needed.  
  > **username_0**: 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!  
  
  ---
  
  ### Answer by username_0 on 2014-07-11. Score: 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,
  
  ```
  
  
  ---
  
  