-
Notifications
You must be signed in to change notification settings - Fork 142
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
Allow to filter query_args in post_select ajax call #744
base: master
Are you sure you want to change the base?
Allow to filter query_args in post_select ajax call #744
Conversation
I can see how this would be useful, but - since editors containing shortcodes can appear in more places than just on a post edit screen - I think we might need to figure out a more abstract way of representing the context of the current editor, which then can be passed into queries like ajax call for 'post_select' fields. I have a branch started locally trying to address this for #661 which I need to polish up. I'll see if it can work well with what you have here. Finally, it might be good to see the javascript logic live inside the parent class |
Thanks @goldenapples interested to see how you did the abstraction. |
js/src/views/select2-field.js
Outdated
@@ -43,7 +43,8 @@ sui.views.editAttributeSelect2Field = sui.views.editAttributeField.extend( { | |||
var request = { | |||
include : _preselected, | |||
shortcode : this.shortcode.get( 'shortcode_tag'), | |||
attr : this.model.get( 'attr' ) | |||
attr : this.model.get( 'attr' ), | |||
postid : $( '#post_ID' ).val() |
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.
There's actually one other place in select2-fields.js where we should be passing the post ID. Can we also add the postid
argument to the search ajax request here?
(Sorry, I think I highlighted the wrong array in my earlier comment - this is the request for initially loading the preselected posts when opening a shortcode ui.)
@goldenapples lol i didn't realize that either. I updated the PR |
I add post id to the post_select ajax call, then a allow to alter the query args for more extendability.
This will solve my issue that return the post list based on which post type it's currently editing.
and it also can fix this issue #625