views:

42

answers:

1

I've created two plugins (A and B), where plugin B is dependent on plugin A.
In plugin A I use jQuery UI Dialog for user interaction and this works fine.

Dependency: Plugin A is a filebrowser. Clicking a button opens a dialog window where user can select file to relate to wordpress post. Plugin A loads all JS necessary to use the dialog box.

Now I try using Dialog box in plugin B and I get an error:

(this.uiDialogTitlebarCloseText = c("<span/>")).addClass("ui-icon ui-icon-closethick").text(m.closeText).appendTo is not a function

Plugin B


I'm testing with very simple code:

// Javascript code from custom_plugin.js
jQuery(document).ready(function() {
  jQuery('#dialog').dialog();
});  

// Code from my custom_plugin.php
<div class="icon32" id="icon-tools"><br></div>
<h2>Gallery manager</h2>

<div id="poststuff" class="metabox-holder">
  <div id="post-body">
    <div id="post-body-content">
      <div id="dialog" title="File browser"> This is a dialog.</div>                               
    </div>
  </div>       
</div>

I have no idea why I'm getting this error. Any suggestions on how I can resolve this?

Plugin A


This is the codeI use in plugin A. I'm getting the above error without ever interacting with plugin A.The scripts for plugin A is just loaded normally.

  jQuery("#fileBrowser").dialog({
        title: "File browser",
        modal: true,
        autoOpen: false,
        height: 700,
        width: 800,
        open: function() {
          jQuery("#fileBrowser").load("../wp-content/plugins/wp-filebrowser/fileBrowser.php", function() {

            // Clear input / feedback text when entering new folder name
            jQuery('#newDirDialog input[type=text]').focus(function() {
              jQuery(this).val('');
              jQuery('.newDirFedback').fadeOut(function(){ jQuery(this).empty(); });
            });

            // Initialize create new dir dialog window
              jQuery("#newDirDialog").dialog({ 
                autoOpen: false, modal: true, title: "New dir"
              });
          });
        }
      }
  ); 

  //Open dialog box on click from WP admin         
  jQuery('.addImage').click(function() {
    imageUrlInputBox = jQuery(this).siblings(":text");
    imagePreviewLink = jQuery(this).siblings("a");
    jQuery("#fileBrowser").dialog("open");
  });
+1  A: 
Pointy
But this is code which is located inside the `jQuery.dialog` script. I'm adding the jQuery code I'm using in plugin A and hope that it will help.
Steven
Are you setting a language context in plugin B? Post the code from that plugin perhaps, since that's where the error's coming from.
Pointy
I've added all the code I have for Plugin B.
Steven
Hmm that's bizarre. I still suspect that's what's messing up the jQuery UI dialog code, but it's hard to say how that'd happen. What version of jQuery UI are you using (and jQuery for that matter)?
Pointy
I'm using `jQuery UI 1.8.2` and `jQuery 1.4.2` - the default ones that come with WP. What can I do to check the `m.closeText`?
Steven
Well that "closeText" thing is supposed to come from the default "options" block that the dialog code uses. It can be overridden of you want the text at the top to say something other than "Close". I can't for the life of me figure out how it'd end up being "undefined", but I also can't figure out how else you'd get that exception. I'll keep thinking but I'm pretty stumped.
Pointy
If I were you I'd try using the un-minified versions of jQuery and jQuery UI, and then see if one of the good debuggers (Firebug, Chrome, even IE8) can help you see what's getting munged.
Pointy
huh.... you were right. I didn't get the error on load when I added the default close text. Really weird. But now clicking the button, I get a new error: `i is undefined`.....
Steven
I discovered what was wrong. I had duplicate function in another javascript. That was why it acted so weird. Thanks for helping though. I'll give you points for that :)
Steven
Awesome, I'm glad you found the problem! It's nice that nowadays there are fairly decent debuggers to help with problems like that.
Pointy