• Hi everyone,

    I have tried to use date-picker in quick edit screen for date input box but it doesn’t swap value to input when i select any date from date-picker.

    It shows value only when i close quick edit screen and going back there again. Can anyone help me to solve out this issue?

Viewing 2 replies - 1 through 2 (of 2 total)
  • I’m running into the same situation. What seems to be happening is that the date picker expects each of its instances to be unique. However, in quick edit, this isn’t the case. The post row is unique, but the edit form is shared by all of the posts. As such, date picker doesn’t pick and push the data back.

    Now, have you been able to overcome this?

    Date picker does work in bulk edit though.

    I just spent several hours grappling with this, but I found the solution (Michael’s comment about unique datepicker instances set me on the right path)!

    First, what I was doing wrong: I was outputting the JS call to datepicker() in the callback attached to WP’s quick_edit_custom_box action.

    The solution is to output it in the re-definition of inlineEditPost.edit()!

    In other words, do something like this:

    add_action ('quick_edit_custom_box', 'add_quickedit_field', 10, 2) ;
    add_action ('admin_footer-edit.php', 'quick_edit') ;
    
    function
    add_quickedit_field ($name, $type)
    {
     ?>
      <fieldset class='inline-edit-col-right'>
        <div class='inline-edit-col'>
          <label>
            <span class='title'>My Datepicker Field</span>
            <span class='input-text-wrap'>
              <input type='text' name='<?php echo $name ?>' />
            </span>
          </label>
        </div>
      </fieldset>
    <?php
    
      return ;
    }
    
    function
    quick_edit ()
    {
     ?>
       <script type='text/javascript'>
        function
        My_QuickEdit ()
        {
          var _edit = inlineEditPost.edit ;
          inlineEditPost.edit = function (id) {
            var args = [].slice.call (arguments) ;
            _edit.apply (this, args) ;
    
            if (typeof (id) == 'object') {
              id = this.getId (id) ;
              }
            if (this.type == 'post' || this.type == 'page') {
              // editRow is the quick-edit row, containing the inputs that need to be updated
              var editRow = jQuery ('#edit-' + id) ;
              // postRow is the row shown when the custom post isn't being edited, which also holds the existing values.
              var postRow = jQuery ('#post-' + id) ;
    
              // get the current value
              var value = jQuery ('td.fieldName', postRow).text () ;
    
              // set the value in the quick-editor
              jQuery (':input[name="fieldName"]', editRow).val (value) ;
              // attached the datepicker
              // be sure to set the value before calling datepicker()
              jQuery (':input[name="fieldName"]', editRow).datepicker () ;
              }
            } ;
    
          return ;
        }
      </script>
    <?php
    
      return ;
    }

    Note: the above code is HIGHLY edited from what I got working in my own plugin, and I haven’t tested it in this form…so if it doesn’t work, it should at least give you the idea of what needs to be done.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Datepicker not working in Quick Edit screen’ is closed to new replies.