在查找了关于内联与外部 javascript 的良好做法后,似乎外部总是最好的,所以我有这个代码:
$(function() {
$('textarea').sceditor({
charset: 'UTF-8',
plugins: 'bbcode',
width: "100%",
autoExpand: true,
toolbar: "bold,italic,underline,strike,quote|bulletlist|left,center,right|link,unlink|youtube,emoticon,image|pastetext|removeformat|maximize|source",
style: "/includes/jscripts/sce/jquery.sceditor.default.min.css",
enablePasteFiltering: true,
// Emoticons list
emoticons: {
dropdown: {
":><:": "/includes/jscripts/sce/emoticons/angry.png",
":'(": "/includes/jscripts/sce/emoticons/cry.png",
":dizzy:": "/includes/jscripts/sce/emoticons/dizzy.png",
":D": "/includes/jscripts/sce/emoticons/grin.png",
"^_^": "/includes/jscripts/sce/emoticons/happy.png",
"<3": "/includes/jscripts/sce/emoticons/heart.png",
":huh:": "/includes/jscripts/sce/emoticons/huh.png",
":|": "/includes/jscripts/sce/emoticons/pouty.png",
":(": "/includes/jscripts/sce/emoticons/sad.png",
":O": "/includes/jscripts/sce/emoticons/shocked.png",
":sick:": "/includes/jscripts/sce/emoticons/sick.png",
":)": "/includes/jscripts/sce/emoticons/smile.png",
":P": "/includes/jscripts/sce/emoticons/tongue.png",
":S:": "/includes/jscripts/sce/emoticons/unsure.png",
":woot:": "/includes/jscripts/sce/emoticons/w00t.png",
":whistle:": "/includes/jscripts/sce/emoticons/whistle.png",
";)": "/includes/jscripts/sce/emoticons/wink.png",
":wub:": "/includes/jscripts/sce/emoticons/wub.png"
}}
}).change(function(e){
var $this = $(this),
$preview = $this.siblings('#preview');
});
});
我怎样才能使它在外部包含的文件中正常工作?它是与SCEditor一起使用的代码。