开发者

CodeMirror save itself onBlur

开发者 https://www.devze.com 2023-04-07 17:14 出处:网络
I want to save all CodeMirrors generated by PHP itself onBlur. Here is what I am talking about: while ($db_field = mysql_fetch_assoc($result)) {

I want to save all CodeMirrors generated by PHP itself onBlur. Here is what I am talking about:

        while ($db_field = mysql_fetch_assoc($result)) {
         ...
            var editor = CodeMirror.fromTextArea(document.getElementById("id'.$db_field['id'].'"), {
              lineNumbers: true,    
              matchBrackets: true,
              mode: "application/x-httpd-php",    
              onBlur: id'.$db_fiel开发者_开发技巧d['id'].'.save()
            });
         ...
         }

But it don´t work ... FireBug says: "id1 is not defined" ... how to do it?


I found bug in my code:

        var id'.$db_field['id'].' = CodeMirror.fromTextArea(document.getElementById("id'.$db_field['id'].'"), {
        lineNumbers: true,    
        matchBrackets: true,
        mode: "application/x-httpd-php",
        onBlur: function(){
          id'.$db_field['id'].'.save();
        },
        onChange: function(){
        $("#changeimg").show();
        }     
        });

This works like a charm

0

精彩评论

暂无评论...
验证码 换一张
取 消