Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 975167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:32:35+00:00 2026-05-16T03:32:35+00:00

I have a little problem with Codemirror ( http://codemirror.net/manual.html ) My code: $(document).ready(function ust()

  • 0

I have a little problem with Codemirror (http://codemirror.net/manual.html)

My code:

$(document).ready(function ust()
    {    
        pa_textareas();
    });
    
    function pa_textareas()
    {
            var textarea = document.getElementById('ta_1');
          var editor_1 = new MirrorFrame(CodeMirror.replace(textarea), {
            height: "100%",
            width: "100%",                
            parserfile: ["tokenizejavascript.js", "parsejavascript.js"],
            stylesheet: "js/js_parser/jscolors.css",
            path: "js/js_parser/",
            autoMatchParens: false,
            content: 'test kjskljsklj skjs lkj slkj sl',
            initCallback: function(getContents) { e1_ct  = ''+editor_1.mirror.getCode()+''; },
            onChange: function (n) { e1_ct = ''+editor_1.mirror.getCode()+''; }
          });
              
          var textarea = document.getElementById('ta_2');
          var editor_2 = new MirrorFrame(CodeMirror.replace(textarea), {
            height: "100%",
            width: "100%",                
            parserfile: ["tokenizejavascript.js", "parsecss.js"],
            stylesheet: "js/js_parser/csscolors.css",
            path: "js/js_parser/",
            autoMatchParens: false,
            content: 'blub kasjdkljas dkjas lkdj alskj dlk',
            initCallback: function(getContents) { e2_ct  = ''+editor_2.mirror.getCode()+''; },
            onChange: function (n) { e2_ct = ''+editor_2.mirror.getCode()+''; }
          });
    
    }

I want to insert a button which formats the code, but I get always an error.

Button:

onclick="editor_2.mirror.reindent();" 

Result:
-> "editor_2 is not defined"

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T03:32:37+00:00Added an answer on May 16, 2026 at 3:32 am

    The scope of editor_2 is the function pa_textareas. Since you are calling it using an intrinsic event handler attribute, you can’t reach the variable.

    You should probably be assigning the event handler with JavaScript inside the pa_textareas function.

    Since you are using jQuery (At least I assume you are, there are other libraries with the stupid $ variable):

    jQuery('some selector').click(function () { editor_2.mirror.reindent(); });
    

    Since the anonymous function is declared inside pa_textareas it will have access to variables defined in that scope.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

ich have a little Problem to write a .net code. I have an example
I have little problem with my script. Here is the code. http://pastie.org/2361140 When I
I have a little problem with Jquery getJSON function. my json here { entries:
I have a little problem. This is my code: stackPanelShapesContainer = new StackPanel(); InitializeStackPanle();
i have a little problem with my java socket code. I'm writing an android
I have a little problem with following VHDL code: process (zbroji) begin if rising_edge(zbroji)
I have a little problem with a Thread. I execute the function Receive with
I have this little problem with json. //real json var json1 = {test1:TEST1,test2:TEST2,test3:TEST3,test4:TEST4}; alert(json.test1);
I have little problem. I can't use AcceptVerb.Get on some ASP.NET MVC actions because
I have little problem in my iPhone application code but can not identify. please

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.