Link to home
Start Free TrialLog in
Avatar of mmpd
mmpd

asked on

Javascript error is hiding from me...

First thank you for helping me.

I am building a mobile app using JQuery Mobile and JayData.  The following code snippets demonstrate the problem I am having.  

(function (global, $data, undefined) {

    function registerEdmTypes() {

        function Edm_Int32() { };
        $data.Container.registerType('Edm.Int32', Edm_Int32);
        $data.Container.mapType(Edm_Int32, $data.Integer);

        function Edm_String() { };
        $data.Container.registerType('Edm.String', Edm_String);
        $data.Container.mapType(Edm_String, $data.String);
    };

    registerEdmTypes();

    $data.Entity.extend('smms.Entity.Note', {
        'Id':            { key: true, type: 'Edm.Int32', nullable: false, computed: true },
        'Task':         { type: 'Edm.String', nullable: false, required: true, maxLength: 255 },
        'Category':  { type: 'Edm.String', nullable: false, required: true, maxLength: 255 }
    });

    // Define smms.Entities to include the Notes entity 
    $data.EntityContext.extend('smms.Entities', {
        Notes:          { type: $data.EntitySet, elementType: smms.Entity.Note }
    });

})(window, $data);
// End of javascript file.

  
<!-- The following code is within index.html.  
      Include the necessary javascript files.
-->
<script type="text/javascript" src="./js/Libs/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="./js/Libs/jquery.mobile-1.1.0.min.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/Libs/cordova-1.7.0.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/Libs/JayData-rc1-r1.min.js"></script>
<script type="text/javascript" src="./js/myapp/main.js"></script>


<script type="text/javascript">
    document.addEventListener("deviceready", onDeviceReady, false);

    // once the device ready event fires, you can safely do your thing! -jm
    function onDeviceReady() {
        document.getElementById("welcomeMsg").innerHTML += "Cordova is ready!"
        $('#test').append("<li><h1>Test</h1></li>");

	[b]// It will silently bomb here!  Why and how do I fix it???
        var smmsContext = new smms.Entities({
            name: 'oData',
            oDataServiceHost: 'http://localhost:2343/ApplicationData.svc/'
        });[/b]

        // There is something wrong with the above new statement.
        // If the new statement is commented out then "Notes2" displays.
        // With the new left in "Notes2" doesn't display.  This means
        // that the new statement is bombing out and jumping to the end
        // of the script block.
        $('#notes').append("<li><h1>Notes2</h1></li>");

	// Helper function to format an li item.
        function createItemLI(name, id, css) {
            var li = $('<li></li>').append(name).addClass(css).data('id', id);
            return li;
        }

	// Display the notes as an unordered list.
        $(function () {
            smmsContext.Notes.toArray(function (notes) {
                notes.forEach(function (note) {
                    $('#notes').append(createItemLI(note.Id, note.Task, 'note'));
                });
            });
        });
    }
</script>

<body>
	<div id="welcomeMsg"></div>
	<ul id="test"></ul>
	<ul id="notes"></ul>
</body>

Open in new window


The backend database service is running.  If I type into the browser, 'http://localhost:2343/ApplicationData.svc/' I see a properly formatted xml layout of the service.  If I type into the browser, 'http://localhost:2343/ApplicationData.svc/Notes' I also see two records that are in the table Notes table.

The code bombs within this new statement.  Please help.
var smmsContext = new smms.Entities({
            name: 'oData',
            oDataServiceHost: 'http://localhost:2343/ApplicationData.svc/'
});

Again thank you for your help.
Avatar of Kyle Hamilton
Kyle Hamilton
Flag of United States of America image

Sorry. My previous comment was wrong. I took it out.
ASKER CERTIFIED SOLUTION
Avatar of Kyle Hamilton
Kyle Hamilton
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mmpd
mmpd

ASKER

Thank you once again very much.