Latest custom input for Jeditable uses jWYSIWYG editor by Juan M Martínez. This code has been almost ready for a while. This week I finally had time to fix some outstanding FireFox bugs.

If you are interested in writing your own Jeditable custom inputs read the introduction. You might also be interested in MarkItUp! custom input which is similar to jWYSIWYG input.

To test see the working demo and then download the source.

Usage

First include all needed JavaScript and CSS in your HTML.

<script src="jquery.js"" type="text/javascript"></script>
<script src="jquery.wysiwyg.js" type="text/javascript"></script>
<script src="jquery.jeditable.js" type="text/javascript"></script>
<script src="jquery.jeditable.wysiwyg.js" type="text/javascript"></script>
<link rel="stylesheet" href="jquery.wysiwyg.css" type="text/css">

Now you can use input type wysiwyg. Set onblur to ignore. Otherwise clicking menubar will cause editing to quit. You should also include atleast submit and cancel parameters. All jWYSIWYG settings can be passed using wysiwyg parameter. Check documentation from Juan’s webpage.

$('.editable').editable('http://www.example.com/save.php', { 
    type      : 'wysiwyg',
    onblur    : 'ignore',
    submit    : 'OK',
    cancel    : 'Cancel',
    wysiwyg   : { controls : { separator04         : { visible : true },
                               insertOrderedList   : { visible : true },
                               insertUnorderedList : { visible : true }
                }
    }
});

I tested the code with IE6, IE7, FF2, Safari and Chrome. In case you find any problems drop me a line.


87 Responses to “WYSIWYG Inline Edit with Jeditable”

  1. Ilija Studen says:

    “Working demo” is not working for me (Safari 3.1.2 on Mac OS X 10.5.4). When I click on “edit in place” I get redirected back on http://www.appelsiini.net/projects/jeditable page.

  2. Mika Tuupola says:

    Your browser is following a link in the text. Click anywhere else than on the link. Following a link can be disabled with jQuery. But I just remove the link from example text because it is confusing.

  3. Prashant Sakhuja says:

    Mika, Great work with the script. I was not sure how you are saving the edited text using: http://www.appelsiini.net/projects/jeditable/wysiwyg/php/save.php Can you share the logic for this.

  4. Mika Tuupola says:

    Prashant: Same way as you would you save text with any normal form? Check the source for example scripts. You can ignore all parts which say Textile, unless you plan to use Textile rendering.

  5. Thiago says:

    Dear Mika, The style is applied in the form. You do not think it would be better if it were applied in the input?

    Thus:

    /* apply css or style or both */
    if (settings.cssclass) {
        if ('inherit' == settings.cssclass) {
            input.attr('class', $(self).attr('class'));
        } else {
            input.attr('class', settings.cssclass);
        }
    }
    
    if (settings.style) {
        if ('inherit' == settings.style) {
            input.attr('style', $(self).attr('style'));
            /* IE needs the second line or display wont be inherited */
            input.css('display', $(self).css('display'));                
        } else {
            input.attr('style', settings.style);
        }
    }
    
  6. Mika Tuupola says:

    Thiago: I guess it’s just matter of taste how you want to write selectors. You can style input now with:

    form.editable > textarea {
     color : #F00
    }
    

    If class was applied to input you would:

    textarea.editable {
     color : #F00
    }
    
  7. Ian Tresman says:

    Two suggested features for Jeditable:

    1. Jeditable activates only after “login” (or authentication)

    2. After login, editable areas optionally are (a) all highlighted on the page, and/or (b) highlighted when cursor moves over element.

  8. Mika Tuupola says:

    Ian: Good points, but both of them are something that should be handled outside of the plugin. For example:

    1) Backend should add class editable (or something similar) after authentication to those elements which should become editable.

    2) You are already using jQuery so why not just use jQuery to handle highlighting. Something like:

    $('.editable').hover(
        function() {
            $(this).addClass('hover');
        }, 
        function() {
            $(this).removeClass('hover');
       }
    );
    
  9. none says:

    Where I can find a list of all the options editor jwysiwyg?

  10. Mika Tuupola says:

    From jWYSIWYG homepage.

  11. Ian Tresman says:

    Is you file, save.php available for download somewhere, so we can see how to process the edited text, and pass it back to the original HTML file.

  12. Mika Tuupola says:

    All files are downloadable from Subversion. The example save.php script is pretty rudimentary. It just saves values to new row in database. You can also ignore all Textile parts. They are used for demoing Textile rendering.

  13. Thiago Santos says:

    Hello !

    You wrote a great plugins, but i founded what appear be a “bug”: when the object selected is a true link like: “Google.com When you click, the link is loaded and therefore the input field appears.

    best regards, Thiago Santos

  14. Mika Tuupola says:

    Thiago: I have been thinking for a while is it a bug or feautre :) Meaning should Jeditable override default behaviour link or not. In any case you can fix it with something like:

    $('.editable > a').bind("click", function(){
        return false;
    });
    
  15. Thiago Santos says:

    Thanks for your reply Mika, jEditable could have an option for enable or not this “bug-feature”!

    Thanks again, sucess !

    Thiago Santos

  16. Leo Machado says:

    Hi Mika!

    Where is DB.php file? i search in http://svn.appelsiini.net/viewvc/javascript/trunk/jquery_jeditable/php/

    but i didn`t found! thanks

  17. Mika Tuupola says:

    It is part of PEAR DB library. You can install it from commandline with:

    >pear install DB
    
  18. Leo Machado says:

    Hi again Mike, and sorry for my English..

    this script is very good, and i could adapt to my need, but the only question is when I edit the “editable_textile,” he query the database, but always when I click, he brings an old result.

    Is there any way to eliminate this cache?

    Thank you, Leo

  19. Mika Tuupola says:

    Leo: Do you have example code somewhere online? I am not sure if I understand correctly when the old content comes back. When you start editing or when you submit edited content.

    In any case to me it sounds like your database query fails to save the content.

  20. Doug Beleznay says:

    in comment # 8 you suggest adding the .hover method through jquery – but I have found some problems with that.

    The way that Jeditable resizes itself during editing means that when I click the save or cancel it sometimes does not catch the mouseexit events, so the item stays highlighted.

    I have tried adding a callback function in order to remove it, but that doesn’t work if you click on the cancel button (it looks like the callback isn’t getting called)

    callback : function(){$(this).removeClass(‘hover’);}

    It looks like knight_killer has added callbacks for mouse over and leave at http://stackoverflow.com/questions/152104/problems-using-jeditable-and-autogrow

    I might try that, but was wondering if you had any other thoughts.

  21. Brad says:

    Hey there,

    I’ve been trying to get jeditable working with 90% success – can edit text once, and after that I get the error “DB Error: constraint violation”. I’m new to sqlite/pear, and am trying to understand what could be going on.

    It appears like the db/table got set up right:

    sqlite> .dump BEGIN TRANSACTION; CREATE TABLE config (id INTEGER primary key, token VARCHAR, value TEXT, date DATETIME); INSERT INTO config VALUES; COMMIT; sqlite>

    ... and there are no errors except the “constraint violation” that returns as status for “echo $status = $dbh->query($query);”

    This is pretty much the neatest plugin I’ve ever seen and I’m trying hard to get it to work as-is before I port it over to mysql.

    Thanks so much!

    Cheers, Brad

  22. Touya says:

    I find a bug with loadurl: script:

    $("#editable_discount").editable("/seller/setting_discount", { 
      loadurl  : '/seller/load_discount',
      style  : "display: inline;",
      tooltip   : 'click to edit',
      type      : 'text'
    });
    

    html

    <div id="editable_discount">55555</div>
    

    moves cause the bug:

    1 click editable_discount,modify value into 444,confirm 2 click editable_discount again,then loadurl get 55555 back again, seems IE7 cached the result… should I add t=new Date() somewhere after the loadurl?How to ? Thanks..

  23. Mika Tuupola says:

    Touya: Are you sure your values are saved to database? Does this happen with IE7 only and others work as expected?

  24. Mika Tuupola says:

    Brad: It sounds like your DB installation cannot create sequences. Have you tried with MySQL driver? DB library is actually kinda old and I should rewrite examples using PDO.

  25. Zouz says:

    What if i want the dir to be RTL ???

  26. Peter says:

    Hi Mika,

    Thanks for the very fine work you publish here! Independantly, jEditable and jWysiwyg are very useful work by themselves. I wonder what is the advantage of having them both together? E.g. if I need Wysiwyg, I’d just use jWysiwyg (alone).

    Keep up the good work!

  27. Elen says:

    Hi Mika, thanks for the script, life just got easier with it =)

    but you’ve got to show us how’s your SAVE.PHP is functioning, the link you’ve provided above is empty – http://svn.appelsiini.net/viewvc/javascript/trunk/jquery_jeditable/php/ and erorring…

    here is the code i use to save (which DOES actually update database)

    $newsline = $_POST['value'];
    $ID      = $_POST['id'];
    
    $q_add     = "Insert into news (News,Date) values('".$newsline."',".$CurDate.");";
    $q_edit = 'UPDATE news SET News="'.$newsline.'" WHERE ID='.$ID.';';
    
    if($ID == "no")
    {
        $queue = $q_add;
    }
    else
    {
        $ID = (int)$ID;
        $queue = $q_edit;
    }
    
    mysql_query($queue);
    $NewsID = mysql_insert_id();
    
    mysql_close($db);
    
    // if it's a new entry - disply it:
    if ($NewsID){
        echo '<div class="newsline" id="'.$NewsID.'">'.$newsline.'</div><br /><br />';
    }
    

    and after request is processed it displays: Click to edit which is default placeholder for jeditable…

    i’ve tried displaying it as if it was a new entry tried to return ID and Value back… nothing works

    or i’m just getting it wrongly?

  28. Mika Tuupola says:

    Zouz: I do not understand your question. What is RTL directory?

    Peter: If you just need wysiwyg textarea use jWysiwyg alone. If you want wysiwyg inline editing use Jeditable with wysiwyg input.

  29. Mika Tuupola says:

    Elen: Code has been moved to GitHub. You can also find PHP examples from there.

    If the textholder text is displayed after submitting then your script is not echoing anything back. Also you should not echo html back (unless you also submitted some html). Instead echo just the edited text back.

    If you have example page somewhere online I could help more.

  30. Elen says:

    Hi Mika, thanks for coming back. I’ve sorted the problem… can’t remember how.. i think it was something to do with html code i had and the fact that i had another button on the page as well..

  31. Elen says:

    Hi Mika, got another problem… I need another editable area to use on the same page. Without WYSIWYG… I also need that are to return additional data. Here is the code:

    $(document).ready(function() {
      $('.Name').editable('http://localhost/files/save.php';, {
         submitdata : {table: '".$page."'};
    });
    
    $('.edit').editable('http://localhost/files/save.php', {
        type      : 'wysiwyg',
        onblur    : 'ignore',
        submit    : 'OK',
        cancel    : 'Cancel',
        wysiwyg   : { controls : { separator04 : { visible : true },
                                             insertOrderedList   : { visible : true },
                                             insertUnorderedList : { visible : true }
                                           }
                        }
    });
    
    });

    Where $page – is PHP var (i.e. “friends”). I need extra data to be submited for WYSIWYG as well, so i can pass to save.php a var, which contains a name of a database table to update. Neither ‘Name’ or ‘edit’ works…. Can you please advise how to pass extra var via $_POST to save.php for both above?

  32. Mika Tuupola says:

    Elen: How does your generate HTML look like. Do you actually output the php variables into the JavaScript code. Maybe you should be doing something like this instead:

    $('.Name').editable('http://localhost/files/save.php';, {
        submitdata : {table: '<?php print $page ?>'};
    });
    
  33. Elen says:

    Hi Mika, thanks for replying. i’ve sort it. Apparently it shouldn’t have ” ; ” after closing } in – submitdata : {table: ‘<?php print $page ?>‘}; – i’ve copied it from here (perhaps you want to amend?) – http://www.appelsiini.net/projects/jeditable

    And while i have your attention – can you give me some guidance as how to: 1. within wysiwyg-for-jeditable upload a picture onto the server (thru Browse) 2. create a row in database 3. display picture and save both link to a picture and text added into a databse?

    basically i need for user to be able to create a new entry on the website with ability to upload pictures. Now i can put a link to a picture, providing that picture is already loaded onto the server. But my user is not familiar with any of server technology, so i need to make it simple for her. Algorithm above is only provisional – may be you have a better suggestion within jeditable (like uploading a pic to a temp directory on the server and only save it in the designated folder and database when user submit new entry via wysiwyg-for-jeditable form?). Does this make sense?

  34. Kunal Mukherjee says:

    the packed version of jeditable has an error for a ”;”...pls check. :)

    btw…thanks for sharing such a nice and handy tool. will buy you a beer for sure if we ever meet; the world is too small nd u never know!

  35. svacant says:

    Cool plugin

    I change ajaxoptions but i don’t know how do for reset the status of element

    ajaxoptions : { dataType: ‘json’, success: function(data) { alert(data.result); }

    With this code the form remain append and don’t return automatically to plain text.

  36. Mika Tuupola says:

    Elen: Yes it does make sense. However since I haven’t had need for something similar myself I haven’t tried to do it. I am not sure if current ajaxupload input type even supports that…

    Kunal: Thanks for heads up. Will check. Although one should use minified version with mod_deflate. Packed version cause eval() in each page request. I have been planning to stop generating packed versions.

    svacant: You might want to spy the original plugin code. It looks like this:

    success : function(result, status) {
        $(self).html(result);
        self.editing = false;
        callback.apply(self, [self.innerHTML, settings]);
        if (!$.trim($(self).html())) {
            $(self).html(settings.placeholder);
        }
    },
    
  37. Sean says:

    I’ve found a browser dependent problem. jeditable.wysiswyg works fine for me under the Safari 3.2.1, but fails under Firefix 3.0.5 – It looks like the wysiwyg plugin is not initializing. I’m new-ish at jquery, but given it’s working under Safari, I’m feeling stuck.

    @Error: $("textarea", self).wysiwyg is not a function
    Source File: http://localhost/media
    /js/jquery.jeditable.wysiwyg.js
    Line: 49
    
        plugin : function(settings, original) {
            var self = this;
            /* Force autosave off to avoid "element.contentWindow has no properties" */
            settings.wysiwyg = $.extend({autoSave: false}, settings.wysiwyg);
            if (settings.wysiwyg) {
                _setTimeout(function() { $('textarea', self).wysiwyg(settings.wysiwyg); }, 0);_
            } else {
                setTimeout(function() { $('textarea', self).wysiwyg(); }, 0);
            }
        },
    @
    
  38. Mika Tuupola says:

    Sean: Does the online demo work for you? Runs ok with my FireFox 3.0.5?

    Can you put your code somewhere online so I could test?

  39. Raf says:

    Hi Mika,

    I really like your plugin, it’s exactly what I need but I’m having trouble getting the save function to work.

    The save.php script uses sqlite to function but I don’t think my server has this installed (or is it possible for me to get it running?).

    Is there a way for the save script to save the updates directly on the original page or in a txt file?

    I would love it if the edits could be saved without the need of a database.

    Hope you can help me out.

    Thanks for the awsome plugin! Love it!

    Greetings, Raf

  40. Mika Tuupola says:

    Raf: Example files are just example files. They are not meant for production use. But if you do not need to save anything, but just display the edited content in screen just echod the POST:ed value back from server.

    <?php
    
    print $_POST['value'];
    
    ?>
    
  41. Raf Van Suetendael says:

    Hi Mika,

    I figured it out.

    I now have a save.php writing the value to a txt file named after the id of the div that is edited.

    Thanks again for this awsome plugin!

    Greetings, Raf

  42. Elen says:

    Hi Mika, using your plug in – all fine =) thank you for help.

    Got a question/suggestion: you have Browse option, when inserting image in IE, which doesn’t work for uploading an image to the server.

    is there anyway to make it work? would be brilliant..

    i’m currently trying to integrate http://valums.com/ajax-upload/ , but it’s a bit a pain in the a**.. =( too many additional files to load with the page…

  43. Mika Tuupola says:

    Elen: It is part of jWYSIWYG plugin which is not written by me. I do now know that plugin well enough to give support on it.

    However inserting the image with jWYSIWYG is not supposed to upload anything. You just insert and URL which points to the image.

  44. Doug K. says:

    I wanted to set maxlength on the text fields so I added maxlength : ''; to var settings={

    and

    input.attr('maxlength', settings.maxlength);
    

    after

    input.attr('name', settings.name);
    

    now I just set maxlength: ‘180’ to get a character length of 180 in my text input fields! Excellent!

    Maybe you can add this permanently?

  45. Jean-Marc says:

    Hi, I have been using jeditable and loving it! I am experiencing problems to use it with livequery (make freshly created divs editable), could you post some tips for doing it the right way? Thanks a lot again for making webpages looking like apps!

  46. Mika Tuupola says:

    Jean-Marc: What kind of problems did you encounter? Do you have example page somewhere online?

  47. justin says:

    thank you Doug K for posting the “maxlength” ability. i was looking for a way to implement this control! Mika, jeditable is awesome! great work!

  48. Jasmine says:

    Hey there, maybe it is just me, but I have found that the bold and italic buttons in the WYSIWYG editor do not save. This is apparent even in the demo posted here?

    Trying to fix, any ideas? Will let you know if I come across anything!

  49. Jasmine says:

    Oops I wasn’t checking properly – it IS saving it with styled SPAN tags. Not sure why my displayer isn’t showing them, same with the demo, but it IS saving the italic/bold sections.

  50. Jasmine says:

    Hey there! Very sorry for the spam but I fixed it. It is storing everything with slashes, so upon display, simply use stripslashes and it all works perfect!

  51. Paulo Oliveira says:

    Hi. Congratulations for the great plugin!

    I’m having an hard time here when I try to append a new element to the DOM, on the fly via jQuery, that should become editable, like the other already on the DOM.

    The new element is correctly inserted on the DOM but it doesn’t become editable.

    I’m probably missing something here… My level of expertise with Javascript is not very high and neither I am very familiar with jQuery.

    Anyway, any help from you with this would be very much appreciated!

  52. Paulo Oliveira says:

    Sorry for the spam… as I am just using an offline tests server I guess I should give you an example of the code I’m using:

    In the $(document).ready(function() I added at the beginning, just before the Jeditable call, something like this:

    $('.addTxtBox').click(function(){
        $('.userContent').append('div class="edit_area">NEW DIV</div>');
    }
    
    After this I have the Jeditable call:
    
    $('.edit_area').editable('http://192.168.1.2/webtests/save.php', {
        bla bla bla
        ...
    }
    

    The problem is that it works for the already existing div’s of class=edit_area but any new div created via the jQuery append manipulator doesn’t become editable. If I save the page to a file and examine the source html code I verify that the new div was inserted correctly in the place were it should.

    Any suggestion? Thanks in advance for any help and, again, sorry for the double post.

  53. David Davis says:

    Mika,

    First of all, let me say that I love the jEditable plugin and am using it everywhere I can.

    I have an issue using the ajaxupload custom input. The image uploading is fine. Upon successful completion and all the database stuff is finished, my php script is outputting a little form where users can add a name and caption to the image row. My issue is that if I click anywhere in the form, jeditable initiates again and my form disappears and I get the file upload form again. What would you advise I do?

    Thanks

  54. Mika Tuupola says:

    Jasmine: Thanks for the heads up. Will fix the demo.

    Paulo: You might want to check this link

  55. Mika Tuupola says:

    David: Several ways to do it. You can disable Jeditable by either unbinding the event after submitting:

    $(".editable").editable("http://www.example.com/save.php";, {
         type : "textarea",
         submit : "OK",
         callback: function(value, settings) {
             $(this).unbind(settings.event);
         }
    });
    

    or if you are using new version of Jeditable:

    $(".editable").editable("http://www.example.com/save.php";, {
         type : "textarea",
         submit : "OK",
         callback: function(value, settings) {
             $(this).editable('disable');
         }
    });
    

    and then later enable it again with:

    $('.editable').editable('enable');
    
  56. Aaron says:

    Hi. Thanks so much for all your work on the plugin. Noticed a tiny typo on http://www.appelsiini.net/projects/jeditable .

    In the Textile/Markdown example `type : ‘textarea’` should have a comma after it.

    I’ve used the plugin on several projects lately. Always a joy.

    Thanks again, Aaron.

  57. Mika Tuupola says:

    Aaron: Fixed. Thanks for the heads up!

  58. Anders says:

    Great plugin! Very extensible and easy to use.

    I have one issue though. I would like to activate the editable not by clicking the actual text (or div) but by clicking an icon positioned just above the editable area. I don’t see how that can be done using the options. Am I missing something or do I have to tweak it somehow to get that working?

    Thanks

  59. Anders says:

    ...me again… Please disregard my previous post since my brain wasn’t switched on for that one. It was easilly solved by somethinglike:

    $(’#editableDiv’).trigger(‘click’);

    Thanks again!

  60. Hugo says:

    Hi,

    Experiencing a little problem using the WYSIWYG inline editor with jEditable. I have succesfully installed it and got it actually to work. But here’s the thing: Once I specify options/controls for the wysiwyg editor, these are only being applied to the first ‘editable’ area I activate. Once I click/activate a second or third ‘editable’ area they display the wysiwyg editor with default settings.

    Here’s some code: $('.postContent').editable('editdatabase.php', { name : 'content', submit : 'OK', cancel : 'Cancel', type : 'wysiwyg', onblur : 'ignore', wysiwyg : { controls : { underline : { visible : true }, insertImage : { visible : false }, h1mozilla : { visible : false }, h2mozilla : { visible : false }, h3mozilla : { visible : false }, h1 : { visible : false }, h2 : { visible : false }, h3 : { visible : false } } } });
  61. Hugo says:

    Oh and it’s happening in the working demo as well.. Try clicking first one editable area, then see that every setting has been resetted once you open other editable areas…

  62. Mika Tuupola says:

    hugo: Seems like you just found a bug. Thanks for the heads up. Will fix it soon (unless you already have a patch?).

  63. Hugo says:

    Don’t have a patch yet,looking into it. I think I’ll email you the details of my progress.

  64. Frank says:

    Hi

    Great plugin!

    I´m using the plugin for a newsletter template, it has 4 instances of wysiwyg on the same page. So I dont want to insert in db before user is finished with all of the forms. I am fine with one form, but I need some help with multiple. Anyone?

    Thanks!

  65. justin says:

    Frank, not sure if this will work for your site, but I had a similar challenge with a project (gr8werk.com). What I ended up doing is 1.) inserting an empty row into a temp db, and getting the id number 2.) adding submitdata: { working_on: ’$id_number’ } to the main jeditable function 3.) and inserted all user input into that temp db row and updated those fields as the user continued to edit and 4.) when the user “submitted” the form, all those temp values moved to the final db and were deleted from the temp db. Also, created a cron to delete anything in the temp db more than a few hours old. Not sure if this is the best way to accomplish, but it worked for me. Good luck!

  66. johnp says:

    Great plugin Mika. There seems to be a bug with the indicator setting and Chrome/Safari browsers.

    When I add: indicator : '<img src="images/indicator.gif">', to the defaults, the script no longer works in Chrome/Safari.
  67. brad says:

    Love the editor, however I found that if I put in any of the following characters, they are escaped for some reason upon saving:

    ’ ” \

    ends up being:

    \’ \” \\

    Anyone else notice this, and if so is there a workaround?

  68. Michael Smith says:

    I, like other people here, would like to be able to make elements editable that have been loaded in via the jquery ‘load’ method.

    Is this possible?

    I’m happy to provide a demo if that would help.

  69. CongTroi says:

    Good point, I am using it, but dont know how to do Signed

  70. Markus says:

    Hi Mika, thanks for the great plugin. I’ve been using it with success for some time already. Today I encountered a strange problem and after trying for some hours to solve it I though I’d ask you quickly ‘cause maybe you have encountered this or have an easy explanation.

    For one of my editable divs I use the submit button. Now it happens that if I click the editable area and the submit-button appears, my sidebar (floating right div of my two column layout) moves down and starts only after the editable form. like so.

    normal:
    content side
    after click to editable:
    content
    side

    I’d be glad to get some hint, if possible! Thank you!

  71. Markus says:

    I see that my “drawing” wasn’t posted as intended, another try:

    normal:

    main side

    after click:

    main  
      side
  72. Markus says:

    well, well: I used textile but it is not displayed as it should be. anyways I guess it’s clear what I mean.

  73. Mika Tuupola says:

    brad: You PHP is adding the slashes. Check PHP manual for stripslashes, addslashes and magic_quotes_gpc.

  74. Mika Tuupola says:

    Michael Smith: Check jQuery manual for Why do my events stop working after an AJAX request?.

  75. Jonathan says:

    Thanks for Jeditable, it is brilliant. Only thing is that you have php pulling data to load data into the fields. I am looking for a way to load data from my database on all my span tags before and after editting. Where you have <?php print file_get_contents($url . ‘load.php?id=select_1’) ?> I need to put something in JavaScript to do the same thing.

    My horrible code is like this:

    $(".focus").editable("file.php?Action=SetField&id=<?php echo $_GET['id']?>", {
            indicator : "<img src='images/rotation.gif'>",
                loadurl   : "file.php?Action=GetField&id=<?php echo $_GET['id'] ?>",
          event : "focus",
          width : 150,
          onblur : "submit", 
          style : "inherit" 
      });
    
    <span id="1" class="focus" tabindex="1" style="display: inline"></span>
    

    Is it a hopeless case?

  76. Mika Tuupola says:

    Jonathan: Those file_get_contents() calls are not needed for Jeditable. They are just kind of poor mans CMS emulation for the demo pages.

    You need to use loadurl parameter only if the content of span (or any other) tags differs from what you want to show in the input field when you edit it. For example when you want to edit the element using Textile or Markdown etc.

  77. Nic says:

    Anyone here use this plugin in asp.net web services?

    $(".editable").editable(   function(value, settings) {    
          var myParam = new Object();
    
          myParam.key = "EditedString";
          myParam.param = value;
          alert(myParam.key);
    
          myParam.revert = this.revert;       
          myParam.rtnValue = value;         
          $.getJSON( "WebService/ReceiveEditString",     
                     myParam,                
                     function( json ) {     
                        if( !json.status ) { 
                          myParam.rtnValue = myParam.revert;
                        }
                     }
          );
          return( myParam.rtnValue );      
       },
       { 
          loadurl : "http://www.appelsiini.net/projects/jeditable/php/json.php",
          type   : "select",
          submit : "OK",
          tooltip: "Click here to edit",
          event  : "click" 
       }
    );     
    
    And this is my web Services method.
     [WebMethod]
        public void  ReceiveEditString(String EditedString)
        {
    
            System.IO.File.WriteAllText(@"C:\WriteLines.txt", EditedString.ToString());
    
        }
    

    Could someone tell me why it not work??

  78. josh says:

    Would someone mind telling me how to set up the database for this plugin…everything is working for me with exception to saving.

    I realize this is quite basic for some of you but totally new for me. I would greatly appreciate the explanation.

  79. Max says:

    Can someone tell me how to add a login area so only the person with the correct password can make edits? Thanks.

  80. Dean says:

    How can I make it focus on the WYSIWYG when you first enter it, like the other inline editors do?

    I’ve tried the following in the plugin, and I’ve even tried delaying the focus() with a setTimeout

    $(‘textarea’, self).wysiwyg( $.extend({autoSave: false}, settings.wysiwyg) ).focus();

  81. Jat says:

    I am just adding on to what Doug K has said in his comment. The reason of this comment is to be more clear and nothing else.

    In order to use maxlength parameter you have to do 2 things (just 2 and that’s it):

    1. You have to add this code just under input.attr(‘name’, settings.name);

    Here’s the code that you have to add: input.attr(‘maxlength’, settings.maxlength);

    2. Now you have to call maxlength from your page. For example:

    maxlength : ‘40’

    This only applies to input tag and NOT textarea

  82. Pitaro says:

    As Max asked some post above mine, could you please help us to create an extremely simple backend allowing just the admin to edit elements after login? The best would be to find a working code, ready to use. I’m just a webdesigner with little knowledge about coding, I often use code I found out-of-the-box. I think it would be amazing to be able to use a wysiwyg inline editor like a real cms.

  83. Josh says:

    Back on April 26th Hugo asked about a problem he was having with the control parameter being reset to default when you click/activate a second or third ‘editable’ area.

    I too am experiencing this issue and I’m curious if a solution ever came available?

  84. Josh says:

    I’m only using jeditable with jwysiwyg on one page so my solution is to code my controls directly into the wysiwyg.js file so they will persist. I did this by editing line 63 of the jquery.wysiwyg.js file which originally says var controls = {}. I put my dictionary of controls in here instead of on the .editable().

    I don’t think this is the fault of wysiwyg.js as it’s not receiving the controls value one any clicks beyond the first. I spent about 2.5 hours trying to find the bug. All I can tell you is that all other options are being passed back in correctly including the type: ‘wysiwyg’. Looking at settings.wysiwyg after clicking an .editable shows that it only contains autoSave and no longer has a value for controls.

    Wish I could be of more help, but a deadline looms.

  85. Mika Tuupola says:

    Josh: I am not really using this input anymore so I have not hunted the bug. However if you find a solution a patch would be appreciated.

  86. Zeph says:

    Great info, many thanx! You’re website has been a goldmine of information.

    I have one small question which may or may not be possible.

    How would one allow the onblur event to actually submit data and keep the textarea editable?

    I’ve tried hooking the onblur event with a function and using a $.post() request. However, it only works once and it really doesn’t produce the desired result.

    Any pointers would be helpful.

    Thanks.

  87. Error says:

    I have error with this plguin: I type <test> in the editable text box. When i click edit it show not like <test> but like: <test>. Next time when i click edit its show like : &lt;test&gt; Next time this: &amp;lt;test&amp;gt;... And so own, i dont know where could be the problem, please help!

Leave a Reply



(will not be published)



(you can use Textile for formatting)