[wp-trac] [WordPress Trac] #30505: Backbone subviews cannot be attached directly to DOM elements
WordPress Trac
noreply at wordpress.org
Mon Feb 22 15:08:55 UTC 2016
#30505: Backbone subviews cannot be attached directly to DOM elements
----------------------------+------------------------------
Reporter: rmccue | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Administration | Version:
Severity: normal | Resolution:
Keywords: needs-patch | Focuses: javascript
----------------------------+------------------------------
Comment (by adamsilverstein):
Replying to [comment:6 georgestephanis]:
> Isn't the reason that this requires selectors and not elements so that
it can "re-find" the subviews after a render of the parent view? If it
was a reference to the prior element itself, wouldn't that reference then
be broken upon a redraw of the parent?
Indeed - internally wp.backbone keeps track of the subviews that have been
added to a view - these can be added, removed and replaced etc.
independently. I think the reference as a string (for the 'selector')
makes sense.
Note that you CAN add subviews without a selector, in which case the
subview is 'attached' to the root element of the parent view.
@rmccue can you try your code **without** a selector at all? just pass the
view(s) and options to `wp.Backbone.View.add` (the selector is optional) -
does that do what you need?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/30505#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list