Hello,
I am working on a project and decided to use some JS, for the first time in my life. So far it's been pretty painful :)
Anyway, I am using jQuery with jEditable and jQuery UI confirmation dialog. What I am trying to do, it to restore contents of the table cell if user hits Cancel on jQuery UI dialog, or just hits Esc.
jEditable has "onblur" option that i can set to "cancel", and it works if uses clicks out of the field, so I am trying to achieve something like that with jQuery UI, because currently it just leaves an empty table cell.
I am pretty sure the logic of my script is wrong somehow, so I am trying to figure out what to do to fix it.
Here is the flow of the script:
1. User clicks on a table cell and edits data in jEditable
2. User clicks save, jEditable doe POST to my php script and gets results, which a passed to jQuery UI confirmation dialog.
3. User either confirms or cancels changes. In case of Cancel or Esc, the user presented with a page, as it was before any editing has occured
Thank you in advance,
-i
- $(".editable_textarea").editable("/path/to/my/php_script.php", {
- indicator : "<img src='/am/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;
- }
- });