Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Cannot call method 'showNotification' of undefined. #190

Closed
ghost opened this issue Jul 29, 2013 · 3 comments
Closed

Cannot call method 'showNotification' of undefined. #190

ghost opened this issue Jul 29, 2013 · 3 comments

Comments

@ghost
Copy link

ghost commented Jul 29, 2013

Hey everyone,

Create.js newbie here.

I am assuming that I can get to the point of having Create.js send requests to the server, and then I can wire up the server side. I am using some 'unique' server side technology and there are no Create.js 'helper/interfaces' for it.

I think I am close. However, I am getting the error; "Cannot call method 'showNotification' of undefined."

It is happening on line 1822 of Create.js which is the first line of this code snippet.

restorer = jQuery('body').data('midgardCreate').showNotification({
Uncaught TypeError: Cannot call method 'showNotification' of undefined
          bindTo: '#midgardcreate-edit a',
          gravity: 'TR',
          body: restorables.length + " items on this page have local modifications",
          timeout: 0,
          actions: [
            {
              name: 'restore',
              label: 'Restore',
              cb: function() {
                _.each(restorables, function (instance) {
                  widget._readLocal(instance);
                });
                restorables = [];
                restorer = null;
              },
              className: 'create-ui-btn'
            },
            {
              name: 'ignore',
              label: 'Ignore',
              cb: function(event, notification) {
                if (widget.options.removeLocalstorageOnIgnore) {
                  _.each(restorables, function (instance) {
                    widget._removeLocal(instance);
                  });
                }
                notification.close();
                restorables = [];
                restorer = null;
              },
              className: 'create-ui-btn'
            }
          ]
        });
      });

I have no clue how to debug this.

At the bottom of the page, I have:

            <script type="text/javascript" src="assets/scripts/jquery.js"></script>
            <script type="text/javascript" src="assets/lib/jquery-ui/ui/jquery-ui.js"></script>

            <script type="text/javascript" src="assets/lib/modernizr/modernizr.custom.80485.js"></script>
            <script type="text/javascript" src="assets/lib/underscore/underscore.js"></script>
            <script type="text/javascript" src="assets/lib/backbone/backbone-min.js"></script>
            <script type="text/javascript" src="assets/lib/vie/vie-2.1.0.debug.js"></script>
            <script type="text/javascript" src="assets/lib/rdfquery/jquery.rdfquery.min.js"></script>
            <script type="text/javascript" src="assets/lib/annotate/annotate-min.js"></script>
            <script type="text/javascript" src="assets/lib/create/create.js"></script>

            <script type="text/javascript" src="assets/lib/rangy/rangy-core.js"></script>
            <script type="text/javascript" src="assets/lib/hallo/hallo.js"></script>

        <script type="text/javascript">

            jQuery(document).ready(function() {

                // Prepare VIE
                var v = new VIE();

                v.use(new v.RdfaService());

                // Load Create.js with your VIE instance
                $('body').midgardCreate({
                    //state:  'browse',
                    toolbar:'full',
                    url:     function() { return '/rpc'; },
                    vie:     v
                });

                // Fake Backbone.sync since there is no server to communicate with
                Backbone.sync = function(method, model, options) {
                    if (console && console.log) {
                        console.log('Model contents', model.toJSONLD());
                    };
                    options.success(model);
                };

            });

        </script>

The other weirdness going on is that when I click the 'Edit' in the toolbar, I expect to see the buttons change to 'Save' and 'Cancel', but they are 'Save' and 'Edit'.

ANY help would be greatly appreciated!

Thanks.

@bergie
Copy link
Owner

bergie commented Jul 29, 2013

That sounds like an issue with jQuery UI 1.10. Check out #173. It would be helpful if you can grab the latest git version and try with that.

@ghost
Copy link
Author

ghost commented Jul 29, 2013

Bergie,

That seems to have resolved the issue! Thanks!

Note I say 'seems', because I don't have it working fully yet. But the 'weirdness' with the 'Cancel' button remaining a 'Edit' button is gone and there are no WebKit errors/warnings now.

Further, when I click 'Save', there is a 'Notification' that comes up telling me something has saved. I had not seen that yet.

Now I just need to figure out why I don't see anything being sent to the server in the network tab of Webkit. I'll work through that in the morning.

Thanks again!

Eric

@bergie
Copy link
Owner

bergie commented Jul 29, 2013

@edykstra if you copied the setup from the demo, then it might be just "faking" the save to server. See http://createjs.org/guide/#storage for how to do the server communications.

@bergie bergie closed this as completed Jul 29, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant