New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prepend node? Append existing? Insert at given location? #4
Comments
Also, it might be nice for these methods to allow references to existing nodes, via the W3C DOM API (e.g., If we allowed a function, perhaps that would allow the function to use a selector internally, especially if |
I like the idea of a
The alternative would be require capturing a reference to the selected div:
Or a way to select the parent. But you get the idea. |
I guess we could name it |
Added |
Like selection.select, selection.append and selection.insert can now accept a function which returns a node. This makes it slightly easier to append or insert elements whose name is computed from data, or to append elements that already exist (say from an element pool). There has been much discussion regarding whether the function should return the name of the element or the element itself. Returning a name is less work for the caller, but only supports creating new elements; returning a name is also more consistent with how D3 defines attribute values, but D3 does not allow attribute names to be specified as functions. So, it seemed better to opt for consistency with selection.select and selection.selectAll, which accept functions that return elements, since this is more expressive. Of course, you can still use select and selectAll to append elements, but using append to do that directly is more intuitive. Related #4 #311 #724 #732 #734 #961 #1031 #1271.
first pass at getting .on() to work with Raphael event binding.
Note a difference is that (at least with Chrome 37 and D3 3.4.6) JQuery's prepend() will insert before any text node content while D3's insert(...,':first-child') will only insert before normal nodes, not text nodes. |
Rename
add
toappend
, and introduce a similar methodprepend
for adding to the front.The text was updated successfully, but these errors were encountered: