1

I have MVC2 application and I am trying to automatically resize my Textareafor using Jquery

Code:

 <script type="text/javascript" src="../../Content/jquery.autoresize.js">
    $(document).ready(function () {
        $("#target").autoResize();
    });
</script>

  <%: Html.TextAreaFor(model => model.QDetail, new { @id="target" }) %>

and in my Content Folder I only have query.autoresize.js

On compiling it gives me Microsoft JScript runtime error: 'jQuery' is undefined error

What am I missing ?

Thank you All

1
  • You should include jquery.js file before to jquery.autoresize.js. jquery.autoresize.js has dependecy on jQuery Commented Nov 21, 2013 at 5:54

2 Answers 2

2

first add jquery file then add your code

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>// add jQuery
 //^^^^add jquery file

<script type="text/javascript" src="../../Content/jquery.autoresize.js"></script>
     <script type="text/javascript" >
     $(document).ready(function () {
            $("#target").autoResize();
        });
    </script>
Sign up to request clarification or add additional context in comments.

Comments

2

above your autosize.js add:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>

and then

<script type="text/javascript" src="../../Content/jquery.autoresize.js"></script>
//add here script start tag
<script type="text/javascript">
    $(document).ready(function () {
        $("#target").autoResize();
    });
</script>

and if you are using offline app then download library and add physical path like you added jquery.autoresize.js

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.