jQuery / jEditable and jQuery UI Dialog. Re-populating table cell.

Posted by solefald on Stack Overflow See other posts from Stack Overflow or by solefald
Published on 2010-04-14T23:26:21Z Indexed on 2010/04/15 0:23 UTC
Read the original article Hit count: 598

Filed under:
|
|
|

Hello, this is my first time using JS, so i really have no idea what i am doing.

I have a table with data, and using jEditable to allow a user to edit the data and POST it to my php script. When user hits "Save", it opens jQuery UI with the data from php script and it seems to work fine, however, if the user hits Cancel or Esc to close the jQuery UI dialog, they and up back on the page, but the cell they tried to edit is now completely empty. How do i get the cell re-populated?

Thank you!

$(".editable_textarea").editable("/path/to/my/scrip.php", {
    indicator : "<img src='/images/indicator.gif'>",
    type   : 'textarea',
    submitdata: { _method: "post", uri: "<?php echo $this->uri->segment(3); ?>" },
    select : false,
    submit : 'Save',
    cancel : 'Cancel',
 tooltip   : "Click to edit...",
        cssclass : "editable",
 onblur: "cancel",
 cssclass: "edit_destination",
 callback: 
 function(value, settings) {
          $(this).dialog({
              autoOpen: true,
              width: 400,
              modal: true,
     position: "center",
              resizable: false,
     draggable: false,
     title: "Pending Changes",

              buttons: {
              "Cancel": function() {
                      $(this).dialog("close");
                  },
                  "Confirm Changes": function() {
                      document.findSameDestination.submit();
                  }
              }
          });

          $('form#findSameDestination').submit(function(){
              $(this).dialog('open');
              return false;
          });
  $(this).editable("disable");

   },
 data: 
  function(value, settings) 
 {
       var retval = value.replace(/<br[\s\/]?>/gi, '\n');
       retval = retval.replace(/(<([^>]+)>)/gi, '');
       return retval;
   }
});

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery