Forum Replies Created
-
AuthorPosts
-
February 11, 2015 at 11:18 pm in reply to: ajaxsearch.pro.js collision with inclusion of jquery.ui #3898
eggmatters
ParticipantThanks Ernest. I tried variants of the namespaced & non-namespaced scripts. Sorry I made the wrong assumption there. After looking at your code, I see you are indeed namespacing it correctly. My guess is that jquery (‘$’) is a global variable and in js, when you change something, you change it. What else is wierd is that jquery is just fine. Your code doesn’t appear to have any jquery-ui in it (although I didn’t look too hard) so, it is odd that it breaks. I’ve never seen it before. Thanks for looking into it though.
February 9, 2015 at 7:53 pm in reply to: ajaxsearch.pro.js collision with inclusion of jquery.ui #3819eggmatters
ParticipantI was able to successfull de-register the conflicting scripts and dequeue them, causing the errors to go away:
wp_dequeue_script('wpdreams-aspjquery'); wp_dequeue_script('wpdreams-ajaxsearchpro'); wp_deregister_script('wpdreams-aspjquery'); wp_deregister_script('wpdreams-ajaxsearchpro'); wp_deregister_script( 'jquery' ); . . .This is not ideal as it introduces a dependency on my plugin to your plugin. I am still curious as to why the scripts aren’t compartmentalized. Looking at the high compatibility, minified code, it looks like it shouldn’t case issues as it is, in fact, namespaced.
February 9, 2015 at 7:27 pm in reply to: ajaxsearch.pro.js collision with inclusion of jquery.ui #3818eggmatters
ParticipantLooking at your jquery.ajaxsearchpro.js It looks as if you’ve redefined ‘$’ in context of your plugin. This is also in wpdreams-aspjquery. Disabling these scripts gets jquery-ui to load properly and render my modals but I still get the above ‘not found’ & ‘udefined’ errors.
February 9, 2015 at 6:57 pm in reply to: ajaxsearch.pro.js collision with inclusion of jquery.ui #3815eggmatters
ParticipantThanks for your response and my apologies for the boffed email. I did comment out line 85, and no luck. The behavior I’m describing is a page rendered by my plugin. At it’s core, it is an assembly of shorttags which render formatted html snippets of data made by api calls. Some of these render forms as modal dialogs via qquery-ui. With ajax-search-pro enabled, the dialogs fail to load. Firebug shows the following:
TypeError: $(...).dialog is not a functionI’m seeing the inclusion of jquery-ui in my script loads, but I believe it is a namespace collision with the inclusion of ‘ajax-searchpro.js’.
The page dependent on rendering this data does not include the search bar shortcode, but wp will load the plugin anyway.
My plugin makes several api calls. To ensure that these calls or only made when needed, I wrote a filter will only make api calls etc, if a specific shortcode is included.
I load a local copy of jquery-ui, not the cdn or the built in wp instance. I therefore disable these. I have my own javascript inclusion set to load preferably last:add_action('wp_enqueue_scripts', array(&$this, 'addScriptTags'), 999);And then I deregister jquery & jquery-ui and register my own:
function addScriptTags() { $today = date('Ymd', time()); wp_deregister_script( 'jquery' ); wp_deregister_script('jquery-ui-core' ); wp_deregister_script('spin'); //wp_deregister_script('wpdreams-ajaxsearchpro'); wp_deregister_style('jquery-ui'); wp_register_script('jquery', plugins_url('views/js/jquery.js', __FILE__), array(), null); wp_register_script('jquery-ui-core', plugins_url('views/js/jquery-ui.min.js', __FILE__), array('jquery'), $today, null );When
wp_deregister_script('wpdreams-ajaxsearchpro');is uncommented, I get the following errors:Notice: Undefined index: wpdreams-ajaxsearchpro in /var/www/html/wp-includes/class.wp-scripts.php on line 200 Notice: Trying to get property of non-object in /var/www/html/wp-includes/class.wp-scripts.php on line 200Which is odd because, I specified a pretty higher priority number to my enqueue scripts than you did (me: 999, you: 10). The deregister should definitely be called after your scripts have been registered.
-
This reply was modified 11 years, 3 months ago by
eggmatters.
-
This reply was modified 11 years, 3 months ago by
eggmatters. Reason: add function name for clarity
-
This reply was modified 11 years, 3 months ago by
-
AuthorPosts