0

I'm using the jQuery jeditable to edit a div on a web form. Anything I type into this field regardless of length gets sent to the javascript function without error. But if I copy/paste something instead of typing then the data is not passed to the function, and the field blanks out.

The html looks like this;

<div id="forcb1" class="hidden">
    <div id="genComments" class="editGComms" onClick="getNetID();" > </div>
</div>

The function looks like this;

function getNetID(){
    var netid=$("#idofnet").html().trim(); 

    $(document).ready(function() {
        $(".editGComms").editable("SaveGenComm.php", {     
         indicator  : "Saving...",
         tooltip    : "Click to add...",
         style      : "inherit",
         id         : netid,
         name       : "newvalue"
        });
    });
}
Keith D Kaiser
  • 1,016
  • 2
  • 14
  • 31

1 Answers1

0

Please try the following. (Making Jeditable working on new elements)

Also same problem solved on: How do I capture the input value on a paste event?

<div id="forcb1" class="hidden">
    <div id="genComments" class="editGComms"></div>
</div>
---------------------------------------------------------------
document.getElementById("genComments").addEventListener("click", getNetID);

function getNetID(){
    //$(".editGComms").live('click', function(){
        var netid=$("#idofnet").html().trim();

        $(".editGComms").editable("SaveGenComm.php", {
            indicator  : "Saving...",
            tooltip    : "Click to add...",
            style      : "inherit",
            id         : netid,
            name       : "newvalue"
        });
    //});
}

Here is a new version of the function:

function getNetID(){
    $(".editGComms").live('click', function(){
        var netid=$("#idofnet").html().trim();

        $(".editGComms").editable("SaveGenComm.php", {
            indicator  : "Saving...",
            tooltip    : "Click to add...",
            style      : "inherit",
            id         : netid,
            name       : "newvalue"
        });
    });
}

I've also removed the "hidden" from the parent div in order to see the box (for now). But now I can't select the box (I can't put my cursor in the div) to type or paste into it.

Community
  • 1
  • 1
Michael Seltene
  • 543
  • 1
  • 5
  • 17
  • I put your suggestion in place. But when I executed it I got; TypeError: null is not an object (evaluating 'document.getElementById("genComments").addEventListener') – Keith D Kaiser Jan 26 '17 at 19:04
  • I see. You have class="hidden". Try
    to see if it work for test......... if this dont work then uncomment the live.click {(....)} and comment out the addeventlistener part
    – Michael Seltene Jan 26 '17 at 19:21
  • I made the function look like the edit above. However I can't put my cursor in the box (div) in order to type. It doesn't go into edit mode. – Keith D Kaiser Jan 26 '17 at 19:39