Avatar of 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);


    $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!"

	[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/'

        // 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.

	// 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'));

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

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.
JavaScriptResponsive Web

Avatar of undefined
Last Comment

8/22/2022 - Mon
Kyle Hamilton

Sorry. My previous comment was wrong. I took it out.
Kyle Hamilton

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

Thank you once again very much.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.