NaughtySquid
NaughtySquid

Reputation: 2097

change this js code from inline to external

After looking up good practices on inline vs external javascript it seems external is always best, so i have this code:

$(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');

        });
});

How can I make it so that works correctly when in an externally included file? It's code used with SCEditor.

Upvotes: 0

Views: 78

Answers (1)

Arun P Johny
Arun P Johny

Reputation: 388316

Just copy this content to a file like myjs.js and include the file in you page using

<script src="myjs.js"></script>

Since it is using jQuery, this file inclusion should happen after jQuery is inlcuded

Upvotes: 3

Related Questions