Hi, I'm Marnix and I'm currently trying to get JQuery mobile to work with Wordpress, but unfortunately due to the way wordpress generates all it's links in the source with PHP they all come without a "rel" attribute. This causes problems with links towards the admin panels from Wordpress. These admin pages need to be treated as a rel="external" or "data-ajax=false" by JQuery mobile and it needs to completely reload the admin page with the admin.css files for these pages.
As wordpress is a platform others build on as well I don't want to mess around in its source code so I hope to be able work around this with JQuery selectors and add the "data-ajax=false" to these links.
My idea was to do the following
1. I want to find all links to the admin pages (this needs to be done on every page change not just the initial homepage)
2. And I wish to add data-ajax=false to these links
(now here is the problem, I'm probably an absolute retard for thinking it could possibly work this way, so please enlighten me on where I'm wrong) :
I created an extra javascript file inside my /js/ folder for my theme, called custom.js, the only code in it currently is:
- $(document).bind("mobileinit", function(){
- $("a":contains('/wp-admin/')).add(" data-ajax=false ");
- });
I'm gonna try and explain my steps in the hope someone with more experience in JQuery can help me out:
I started with the BLANK Theme for wordpress (it can be downloaded here:
http://themeclubhouse.digwp.com/. I've put the code (block 1) in the functions.php file, and copy pasted the JQuery mobile style definitions into the already existing style.css for the theme under the rest of the @media screen.
- // Load jQuery
- if ( !is_admin() ) {
- wp_deregister_script( 'jquery' );
- wp_register_script( 'jquery' , ( "http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js" ), false );
- wp_enqueue_script( 'jquery' );
- }
- // Load custom.js
- if ( !is_admin() ) {
- wp_deregister_script( 'custom-script' );
- wp_register_script( 'custom-script' , get_template_directory_uri() . '/js/custom.js' , false );
- wp_enqueue_script( 'custom-script', get_template_directory_uri() . '/js/custom.js' , array('jquery') );
- }
-
- //Load jQuery Mobile
- if ( !is_admin() ) {
- wp_deregister_script( 'jquery.mobile' );
- wp_register_script( 'jquery.mobile' , ("http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"), false);
- wp_enqueue_script( 'jquery.mobile' , "http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js" , array( 'jquery'));
- }
I hope someone with more knowledge than myself can clarify some things I'm doing wrong. Any help will be much appreciated!