Home › Forums › General Issues › jQuery and new field type › Reply To: jQuery and new field type
Hi @elliot,
thank you for your answer. I have already read this article, but I don’t reaklly understand it. Do I have to create the acfg/setup_fields action in my wordpress functions.php or directly into my HTML in the create_field function() ?
My create_field function looks like this now. But it doesn’t work 🙁
function create_field( $field )
{
// defaults?
/*
$field = array_merge($this->defaults, $field);
*/
// perhaps use $field['preview_size'] to alter the markup?
// create Field HTML
?>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script>
$(document).live('acf/setup_fields', function(e, div){
// div is the element with new html.
// on first load, this is the $('#poststuff')
// on adding a repeater row, this is the tr
$(div).find('.class').each(function(){
$(this).doIt();
});
});
function doIt() {
alert("Hello World!");
}
</script>
<div id="dialog" title="Basic dialog">
<p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
</div>
<?php
}
Cheers,
javanese
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.