I'm building a plugin for my web site and I'm working on the admin pages. I want to have a number of tabs across the top & I need a dialog box that pops up when the user clicks on a link.
I've got the tabs functionality working for my plugin. It's only taken me 4 days to figure it out, but I've got it working. I'm using jquery.ui.tabs for the tabs.
The admin page contains a list of items. The name of each item is a link. When you click on the link, I want a dialog box to display that contains information about that item & will let you edit it. When you click OK, the page should be submitted using the POST method & the edits processed.
Here's the code for the admin page that loads the scripts. This is a method of a class.
function load_scripts() {
// Load our scripts
wp_enqueue_script( 'jquery-ui-tabs' );
add_thickbox();
wp_enqueue_script( 'as-admin-js', AS_URLPATH . 'js/admin.js' );
}
The plugin loads jquery & jquery.ui.core in it's load_scripts() method, so I found I didn't need to call wp_enqueue_script() for those in the admin class. I'm not sure if I'm calling add_thickbox() in the right place or not.
Here's my code in admin.js:
function showDialog( windowId, row, col, name, type, label, cls, id, maxlength, size, tab, keywords, others, min, max, value ) {
// Set the values of the form"s controls to the values we were passed
document.getElementsByName( "row" )[ 0 ].value = row;
document.getElementsByName( "col" )[ 0 ].value = col;
document.getElementsByName( "name" )[ 0 ].value = name;
document.getElementsByName( "label" )[ 0 ].value = label;
// more lines like these
. . .
// Finally, have thickbox display the dialog box
tb_show("", "#TB_inline?width=640&height=330&inlineId=" + windowId + "&modal=true", false);
}
I have stepped through my code in the Firefox JavaScript debugger & all of the statements run fine. I have the dialog box part of the page visible so I can see the fields getting loaded with their values. But, when the tb_show() is executed, no dialog box.
Here's what one of the links to the call looks like after it's been emitted by the PHP code:
<a href="" onclick="showDialog('field_editor', 0, 0, 'date', 'label', 'Date Must Be:', '', '', '16', '25', '0', '', '', '', '', ''); return false;" >date</a>
I'm also not sure if I've got the anchor tag coded right. Do I need the href
=""?
Thanks for any help anybody can give me.
Tony