pods-framework / pods

The Pods Framework is a Content Development Framework for WordPress - It lets you create and extend content types that can be used for any project. Add fields of various types we've built in, or add your own with custom inputs, you have total control.
https://pods.io/
GNU General Public License v2.0
1.07k stars 264 forks source link

select2 jquery conflict when using autocomplete format #4141

Closed mikexavier closed 7 years ago

mikexavier commented 7 years ago

I'm having a strange issue when using format: autocomplete. I've added a custom field to woocommerce products which allows the client to select different times. All times are entered into "Custom defined options". When it's set to autocomplete I can no longer move the metaboxes, use the dropdowns (for example "screen options" or toggle a metabox open or closed. Screen shots attached of current settings.

When I change it to multi-select however, everything works fine.

Console gives me: Uncaught TypeError: Cannot read property 'apply' of undefined at HTMLInputElement. (select2.full.js?ver=4.0.3:6396) at Function.each (load-scripts.php?c=1&load[]=jquery-core,jquery-migrate,underscore,utils,jquery-ui-core,jquery-ui-wi…:2) at a.fn.init.each (load-scripts.php?c=1&load[]=jquery-core,jquery-migrate,underscore,utils,jquery-ui-core,jquery-ui-wi…:2) at a.fn.init.$.fn.select2 (select2.full.js?ver=4.0.3:6386) at HTMLDocument. (post.php?post=1798&action=edit&lang=en:4191) at i (load-scripts.php?c=1&load[]=jquery-core,jquery-migrate,underscore,utils,jquery-ui-core,jquery-ui-wi…:2) at Object.fireWith [as resolveWith] (load-scripts.php?c=1&load[]=jquery-core,jquery-migrate,underscore,utils,jquery-ui-core,jquery-ui-wi…:2) at Function.ready (load-scripts.php?c=1&load[]=jquery-core,jquery-migrate,underscore,utils,jquery-ui-core,jquery-ui-wi…:2) at HTMLDocument.K (load-scripts.php?c=1&load[]=jquery-core,jquery-migrate,underscore,utils,jquery-ui-core,jquery-ui-wi…:2) load-scripts.php?c=1&load[]=thickbox,hoverIntent,common,admin-bar,heartbeat,autosave,wp-ajax-respon…:652 Uncaught TypeError: Cannot read property 'hasClass' of undefined at HTMLDocument. (load-scripts.php?c=1&load[]=thickbox,hoverIntent,common,admin-bar,heartbeat,autosave,wp-ajax-respon…:652) at HTMLDocument.dispatch (load-scripts.php?c=1&load[]=jquery-core,jquery-migrate,underscore,utils,jquery-ui-core,jquery-ui-wi…:3) at HTMLDocument.r.handle (load-scripts.php?c=1&load[]=jquery-core,jquery-migrate,underscore,utils,jquery-ui-core,jquery-ui-wi…:3) at Object.trigger (load-scripts.php?c=1&load[]=jquery-core,jquery-migrate,underscore,utils,jquery-ui-core,jquery-ui-wi…:3) at Object.a.event.trigger (load-scripts.php?c=1&load[]=jquery-core,jquery-migrate,underscore,utils,jquery-ui-core,jquery-ui-wi…:9) at HTMLDocument. (load-scripts.php?c=1&load[]=jquery-core,jquery-migrate,underscore,utils,jquery-ui-core,jquery-ui-wi…:3) at Function.each (load-scripts.php?c=1&load[]=jquery-core,jquery-migrate,underscore,utils,jquery-ui-core,jquery-ui-wi…:2) at a.fn.init.each (load-scripts.php?c=1&load[]=jquery-core,jquery-migrate,underscore,utils,jquery-ui-core,jquery-ui-wi…:2) at a.fn.init.trigger (load-scripts.php?c=1&load[]=jquery-core,jquery-migrate,underscore,utils,jquery-ui-core,jquery-ui-wi…:3) at Object. (load-scripts.php?c=1&load[]=thickbox,hoverIntent,common,admin-bar,heartbeat,autosave,wp-ajax-respon…:343)

Is there a workaround for this?

thanks guys

screen shot 2017-04-29 at 22 06 42 screen shot 2017-04-29 at 22 12 31
sc0ttkclark commented 7 years ago

Which version of Pods are you using? It looks like you hit a snag, a more recent version of Select2 was likely active which Pods doesn't (yet) support in our current stable version on WordPress.org. We have it upgraded and available in our upcoming Pods 2.7 beta we'll be announcing in the next week or so.

The best way to move forward on this is to give us a list of plugins you have active and we'll see if we can find a workaround for you to disable the select2 script on the pages we have Pods admin forms.

sc0ttkclark commented 7 years ago

Please also give us the version number with each plugin you've got running. So far we're thinking it's a WooCommerce issue with their newer Select2.

sc0ttkclark commented 7 years ago

As I read further into your issue, I can see you are trying to add this field into a post type that's run by WooCommerce, which means we can't disable their Select2 to get our code to work. I suggest you use something other than an autocomplete (for now) until Pods 2.7 comes out.

mikexavier commented 7 years ago

ok, thanks for letting me know Scott… will do as you suggested :)

Mike

On 30 Apr 2017, at 05:43, Scott Kingsley Clark notifications@github.com wrote:

As I read further into your issue, I can see you are trying to add this field into a post type that's run by WooCommerce, which means we can't disable their Select2 to get our code to work. I suggest you use something other than an autocomplete (for now) until Pods 2.7 comes out.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/pods-framework/pods/issues/4141#issuecomment-298209158, or mute the thread https://github.com/notifications/unsubscribe-auth/AQW8qk_dkoZd3-vnFOHbap0w636S3I4oks5r1ANogaJpZM4NMXo_.

Ramoonus commented 7 years ago

can we build some soft of version detect if select2 is already loaded?

mikexavier commented 7 years ago

I’m not quite sure what that involves… could you elaborate?

thx

On 30 Apr 2017, at 12:41, Ramon van Belzen notifications@github.com wrote:

can we build some soft of version detect if select2 is already loaded?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/pods-framework/pods/issues/4141#issuecomment-298224585, or mute the thread https://github.com/notifications/unsubscribe-auth/AQW8qq5xrVmBu75V_mYEYSNtEcyBpbY9ks5r1GVOgaJpZM4NMXo_.

sc0ttkclark commented 7 years ago

@Ramoonus Open to ideas there, but it won't be an issue too much longer until Pods 2.7 comes out.

garypaul commented 7 years ago

Wouldn't the patch in https://github.com/pods-framework/pods/pull/4127 work to fix this problem in the meantime?

pglewis commented 7 years ago

The update to select2 4.0 in that branch is designed around the new DFV fields in 2.7 and wouldn't simply merge into 2.x without additional work, unfortunately.

pglewis commented 7 years ago

2.7 is already using select2 4.0, so this is fixed once that lands.

Also considering keeping a private reference of our own to avoid future conflicts: #4178