Answers.Body: <p>You can see how this is working by opening craft/app/resources/js/craft.js and searching for the <code>Craft.EntryIndex</code> class definition.</p>
  
  <p>Craft.EntryIndex is an extension of Craft.BaseElementIndex, and is used to govern <em>all</em> Entry indexes in Craft (including Entry selection modals). We pull that off with this line of code, which you’ll find immediately after the class definition:</p>
  
  
  
  <pre class="lang-js prettyprint-override"><code>Craft.registerElementIndexClass('Entry', Craft.EntryIndex);
  </code></pre>
  
  <p>The logic governing the “New Entry” button is a little complicated, and it relies on an initial version of the button HTML already being available on the page (thanks to the craft/app/templates/entries/_edit.html template), but all the magic happens within its onSelectSource() method, including updating the URL.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-06T17:01:33.810Z
Answers.Text: Very interesting... I started to go down that path, but wanted to make sure I was headed in the right direction. I'll take another crack at it with this information in mind. Thanks Brandon! :)
Answers.UserDisplayName: Lindsey D
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-06T13:26:22.280Z
Answers.LastActivityDate: 2015-08-06T13:26:22.280Z
Answers.UserDisplayName: Brandon Kelly
Body: <p>I have a split-style <code>+ New Element</code> button for my custom element type. Thanks to <a href="https://craftcms.stackexchange.com/q/10838/45">this previous thread</a>, the right-side dropdown menu is working perfectly!</p>
  
  <p><a href="https://i.sstatic.net/4lqDA.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/4lqDA.png" alt="Split button"></a></p>
  
  <p>My question now is, <strong>how do I get the <code>+ New Element</code> side of it working?</strong></p>
  
  <p>I keep studying the <code>entries</code> templates, to see how it's done over there. But I've noticed that when you navigate between entry sources, <em>the page URL actually changes</em>. When navigating between my custom element sources, the page URL does not change.</p>
  
  <p><strong>How can I help the <code>+ New Element</code> button detect what source is currently being viewed?</strong></p>
  
Tags: <plugin-development><elementtype>
Title: Detect currently selected source of custom elements
ThreadText: # Detect currently selected source of custom elements
  
  (Asked by: username_0 on 2015-08-06)
  
  I have a split-style `+ New Element` button for my custom element type. Thanks to [this previous thread](https://craftcms.stackexchange.com/q/10838/45), the right-side dropdown menu is working perfectly!
  
  [![Split button](https://i.sstatic.net/4lqDA.png)](https://i.sstatic.net/4lqDA.png)
  
  My question now is, **how do I get the `+ New Element` side of it working?**
  
  I keep studying the `entries` templates, to see how it's done over there. But I've noticed that when you navigate between entry sources, *the page URL actually changes*. When navigating between my custom element sources, the page URL does not change.
  
  **How can I help the `+ New Element` button detect what source is currently being viewed?**
  
  **Tags:** plugin-development, elementtype
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-08-06. Score: 3 | Accepted answer
  
  You can see how this is working by opening craft/app/resources/js/craft.js and searching for the `Craft.EntryIndex` class definition.
  
  Craft.EntryIndex is an extension of Craft.BaseElementIndex, and is used to govern *all* Entry indexes in Craft (including Entry selection modals). We pull that off with this line of code, which you’ll find immediately after the class definition:
  
  ```js
  Craft.registerElementIndexClass('Entry', Craft.EntryIndex);
  
  ```
  
  The logic governing the “New Entry” button is a little complicated, and it relies on an initial version of the button HTML already being available on the page (thanks to the craft/app/templates/entries/\_edit.html template), but all the magic happens within its onSelectSource() method, including updating the URL.
  
  > **Comments:**
  > **username_0**: Very interesting... I started to go down that path, but wanted to make sure I was headed in the right direction. I'll take another crack at it with this information in mind. Thanks username_1! :)  
  
  ---
  
  