I have a script that creates a custom metabox and makes it possible to upload multiple images to one page post.
It gives me no error but the console tells me this:TypeError: add_field_row is not a function
This is the JQuery:
<script type="text/javascript">
function add_image(obj) {
var parent=jQuery(obj).parent().parent('div.field_row');
var inputField = jQuery(parent).find("input.meta_image_url");
tb_show('', 'media-upload.php?TB_iframe=true');
window.send_to_editor = function(html) {
var url = jQuery(html).find('img').attr('src');
inputField.val(url);
jQuery(parent)
.find("div.image_wrap")
.html('<img src="'+url+'" height="48" width="48" />');
// inputField.closest('p').prev('.awdMetaImage').html('<img height=120 width=120 src="'+url+'"/><p>URL: '+ url + '</p>');
tb_remove();
};
return false;
}
function remove_field(obj) {
var parent=jQuery(obj).parent().parent();
//console.log(parent)
parent.remove();
}
function add_field_row() {
var row = jQuery('#master-row').html();
jQuery(row).appendTo('#field_wrap');
}
</script>
I don't see where I go wrong. And if I'm not mistaken I don't need to use the ready() because I'm not using a $
jQuery(document).ready(function($){
// now you can use jQuery code here with normal $ shortcut formatting
});
I've tried to be sure but same error.
Any help please.
Aucun commentaire:
Enregistrer un commentaire