Click here to Skip to main content
15,921,113 members
Please Sign up or sign in to vote.
1.67/5 (2 votes)
See more:
i have this index.html file :


XML
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>


    <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="content/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="content/main.css">
    <!-- jQuery library -->
    <!-- <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>-->
    <script src="scripts/jquery.min.js"></script>
    <!-- Latest compiled JavaScript -->
    <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
    <script src="scripts/bootstrap.min.js"></script>
    <script src="App/data.js"></script>
    <script src="App/main.js"></script><!---calling all the .int files -->


    <style type="text/css">


        #main_light_layover {

            width:20px;
            height:20px;
            padding:20 20;
            background-color:yellow;
        }
        #main_deep_layover {
             width:20px;
            height:20px;
            padding:20 20;
            background-color:green;
        }

        #main_regular_layover {
             width:20px;
            height:20px;
            padding:20 20;
            background-color:purple;
        }

    </style>
  </head>

<body>
    <div id="main_right_line_one">  one </div>

    <div id="main_right_line_two"> two </div>

    <div id="main_right_line_three">three </div>

    <div id="main_light_layover"> </div>
    <div id="main_deep_layover"> </div>
    <div id="main_regular_layover"> </div>
</body>
</html>






then i have this main.js file where i should include all the .init() functions:

C#
    var main=(new function(){
        var me=this;

        me.init=function(){
            divEditScreen.init();

        }

}());


$(document).ready(function () {

    main.init();

});





"divEditScreen" is a variable with directory : App --> Users --->Edit.js // the main.js directory is App -->main.js .


inside this file (App --> Users --->Edit.js)

C#
var divEditScreen = (new function () {
    var me = this;

    me.init = function () {
        $("#main_right_line_one").click(function () {
            me.fade();
        });
    }




    me.fade = function () {
        $('#main_regular_layover, #main_deep_layover').fadeOut('slow', function () {
            $('#main_light_layover').fadeIn('slow');
        });
    }







}());






why do i get an error that divEditScreen is not defined ?
Posted
Comments
F-ES Sitecore 5-Sep-15 7:56am    
Check the order that you code is running, it could be the function is being accessed before it is defined, maybe due to the order of includes or code blocks. It could be your method isn't being defined at all, I see most of the code you have posted is happening inside other blocks of code so we have no way of knowing the context of your code.

Ultimately we can't access your system or run your code so we don't know. Look into using the "debugger;" keyword in conjunction if your browser's dev tools, or even basic "alert" calls to step through your code so you can work out the order things are being called, and what is being called at all. From that you might be able to work it out.
May Bash 5-Sep-15 8:44am    
@F-ES Sitecore i figured out the problem , i should have included
<script src="App/Users/edit.js"></script><!---calling all the .int files -->

in header in HTML page you are right , i wasnt calling the function :) thnx

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900