Skip to content

Commit

Permalink
Apparently jQuery doesn't like square brackets. Now the click event i…
Browse files Browse the repository at this point in the history
…s firing but the autocomplete still isn't working. Hm...
  • Loading branch information
blutz committed Dec 30, 2012
1 parent 8269602 commit 8e3d48e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion js/media-credit-autocomplete.js
@@ -1,6 +1,6 @@
function mediaCreditAutocomplete(id, currAuthorId, currAuthor) {
var PLUGIN_DIR = "../wp-content/plugins/media-credit/"; //TODO: better way to do this?
var inputField = "input#attachments\\\\[" + id + "\\\\]\\\\[media-credit\\\\]"
var inputField = "input#attachments-" + id + "-media-credit"
jQuery(inputField)
// TODO: This is not firing for some reason
.click(function() {
Expand Down Expand Up @@ -35,6 +35,7 @@ function mediaCreditAutocomplete(id, currAuthorId, currAuthor) {
.result(function(event, data, formatted) {
addID(id, data[1]);
});
jQuery(inputField).click();
}

function addID(id, author) {
Expand Down
7 changes: 4 additions & 3 deletions media-credit.php
Expand Up @@ -151,12 +151,13 @@ function get_freeform_media_credit($post = null) {
function add_media_credit($fields, $post) {
$credit = get_media_credit($post);
// add requirement for jquery ui core, jquery ui widgets, jquery ui position
$html = "<input id='attachments[$post->ID][media-credit]' class='media-credit-input' size='30' value='$credit' name='free-form-{$post->ID}' type='text' />";
$html = "<input id='attachments-$post->ID-media-credit' class='media-credit-input' size='30' value='$credit' name='free-form-{$post->ID}' type='text' />";
$author = ( get_freeform_media_credit($post) == '' ) ? $post->post_author : '';
$author_display = get_media_credit($post);
$html .= "<input name='media-credit-$post->ID' id='media-credit-$post->ID' type='hidden' value='$author' />";
$html .= "<script type='text/javascript'>jQuery('input#attachments\\\\[$post->ID\\\\]\\\\[media-credit\\\\]').livequery(function() {
alert('oh');
$html .= "<script type='text/javascript'>jQuery('input#attachments-$post->ID-media-credit').livequery(function() {
console.log(this);
console.log('is that right?');
mediaCreditAutocomplete($post->ID, " . (($author == '') ? -1 : $author) . ", '$author_display');});</script>";
$fields['media-credit'] = array(
'label' => __('Credit:'),
Expand Down

0 comments on commit 8e3d48e

Please sign in to comment.