I'm going to use Xheditor as the new online editor, and I hope it can be used in a PHP function to call
Copy Code code as follows:
function Editor ($content, $name)
{
$editor =<<<eot
<textarea id= "$name" name= "$name" rows= "cols=" > $content </textarea>
EOT;
return $editor;
}
The benefits of doing so are:
1, do not have to call the Xheditor editor every time, in front of write a big
2, the invocation is convenient, the template on the return of the HTML code on the variable can be.
The method I used was to asynchronously xheditor the code with the Get () method in jquery and then run the code with eval.
As follows:
Copy Code code as follows:
function Editor ($content, $name)
{
$editor =<<<eot
$ (document). Ready (
function () {
if (!$.isfunction ($.xheditor))
{
$.get (
'.. /xheditor.js ',
function (data) {
eval (data);
}
);
}
$ (' #{$name} '). Xheditor (True);
}
);
<textarea id= "$name" name= "$name" rows= "cols=" > $content </textarea>
EOT;
return $editor;
}
The code above is correct, you can't run it.
The problem occurs because Xheditor version 0.9.8 is loaded asynchronously. Causes Xheditor to not display properly.
Reason:
Because the jsurl is obtained by getting the page. But I'm using asynchronous loading, so I need to specify the Jsurl address.
Patch:
Open Xheditor.js Find the following code
Copy Code code as follows:
var Defaults={skin: "Default", Tools: "Full", Internalscript:false,inlinescript:false,internalstyle:false, Inlinestyle:true,showblocktag:false,forceptag:true,keepvalue:true,uplinkext: "Zip,rar,txt", UpImgExt: "Jpg,jpeg, Gif,png ", Upflashext:" SwF ", Upmediaext:" avi ", modalwidth:350,modalheight:220,modaltitle:true};
To
Copy Code code as follows:
var Defaults={skin: "Default", Tools: "Full", Internalscript:false,inlinescript:false,internalstyle:false, Inlinestyle:true,showblocktag:false,forceptag:true,keepvalue:true,uplinkext: "Zip,rar,txt", UpImgExt: "Jpg,jpeg, Gif,png ", Upflashext:" SwF ", Upmediaext:" avi ", modalwidth:350,modalheight:220,modaltitle:true,editorurl:null};
is actually adding the default value of Editorurl.
and find it again.
Copy Code code as follows:
This.settings=$.extend ({},defaults,options);
After which you add
Copy Code code as follows:
Jsurl= this.settings.editorurl| | Jsurl;
Used to set whether the Jsurl is using a default or user-defined directory
Later, when you call Xheditor, you have one more argument.
Copy Code code as follows:
Editorurl
The URL path of the editor, which must have "/" and the default value is NULL
Open the root directory load_xheditor.html in the browser
File Packaging