-
Notifications
You must be signed in to change notification settings - Fork 3
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
Editing entities from select2. #12
Conversation
return $.trim( component.select2_result_template( data ) ); | ||
}, | ||
templateSelection: function( data ) { | ||
data.disable_edit = ! data.id; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The id
is not defined when the template is for the “searching” message or for the “no results found” message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, and for placeholders as well.
@westonruter Found that |
@miina This is working exactly how I had envisioned it, but I found an obscure bug. If you drag & drop the order of the posts, then edit one and return focus back to the control the Customizer panel will not scroll up or down. I cannot reproduce the issue without reordering the posts first. |
Instead of making the result text itself a link, what if there was a link added after the text that had the edit dashicon as its content (along with |
I think the scrolling issue is fixed. |
FYI: This same functionality is also proposed for the |
|
||
// Set up the add new post buttons | ||
component.container.on( 'click', '.select2-selection__choice__edit', function() { | ||
var ensuredPromise, returnPromise, postId, $elm = $( this ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The body of this function can now be replaced with a call to api.Posts.startEditPostFlow()
. See https://github.com/xwp/wp-customize-posts/blob/33840418da9dcd7c55d15061de5fe49f85d9058f/js/customize-posts.js#L589-L598
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pointing that out, will take a look.
@@ -111,6 +111,7 @@ wp.customize.ObjectSelectorComponent = (function( api, $ ) { | |||
return $.trim( component.select2_result_template( data ) ); | |||
}, | |||
templateSelection: function( data ) { | |||
data.multiple = component.select2_options.multiple; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a better way how to get it from template that it's multiple select field?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't look like. I checked this
and if there are any other arguments, and I see none. So yeah, looks good.
Fixes #8