Support

Account

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