Wave.getState () returns null

When I try to call wave.getState () on my Google Wave gadget, I return zero (without a state object). How to initialize a Wave state object? I work at Wave Sandbox.

My ModulePrefs contains the following:

<Require feature="wave" /> <Require feature="rpc"/> 

I have a "rpc" function from some google group column when looking for a fix, but that doesn't seem to help.

The gadget contains a jQuery plugin that defines the classes that I use (not shown), attaches an event handler to the link that appears in edit mode, and sets callback methods using the google wave gadget initializer:

 $.fn.extend({ $.gork.InitPass.newButtonClick = function newButtonClick() { var jer = new $.gork.InitPass.Player('Jeremias', 12, 2); var delta = {}; delta[jer.name] = jer.serialize(); wave.getState().submitDelta(delta); }; $.gork.InitPass.modeCallback = function modeCallback() { var state = wave.getState(); var mode = wave.getMode(); $.gork.InitPass.getContainer().ipCombatState(state, (mode == wave.Mode.EDIT)); }; $.gork.InitPass.stateCallback = function stateCallback() { $.gork.InitPass.getContainer().ipCombatState( wave.getState(), (wave.getMode() == wave.Mode.EDIT)); alert('state'); }; $.gork.InitPass.init = function init() { if (wave && wave.isInWaveContainer()) { var mode = wave.getMode(); $('.gork-ip-container').ipCombatState(null, (mode == wave.Mode.EDIT)); wave.setModeCallback($.gork.InitPass.modeCallback); wave.setStateCallback($.gork.InitPass.stateCallback); } }; })(jQuery); gadgets.util.registerOnLoadHandler($.gork.InitPass.init); $(function ready() { $.gork.InitPass.getContainer().find('.gork-ip-edit .addSection a.newButton').click( $.gork.InitPass.newButtonClick); }); 

So, there are two main functions:

  • When the mode changes, ipCombatState (...) is called. This changes the look of the gadget when the user places the gadget in edit mode (CTRL + E), hiding the DIV view and showing the DIV editing.
  • The newButtonClick callback (which is bound to the "a.newButton" link in the edit container) should add Jeremiah (the Nate Shadowrun character) to the gadget state so that it appears as a table row in edit mode.

I checked that the initializer method is being called and the view / edit mode switch works just fine (except for the null state). When I click on the link of a new button (the link below is in edit mode) and run the newButtonClick handler, I get an error message because wave.getState () also returns null.

How can I initialize the state of a wave so that I can work with it?

The goal of my gadget is to track the order of hostilities in the Shadowrun board game (4th edition). You can check it in Wave and see what I still have:

http://gorkwobble.herobo.com/wave/init-pass.xml

Actual javascript code is used for:

http://gorkwobble.herobo.com/wave/init-pass.js

PS If any of the Shadowrun players read this and want to hear about it when I earn the gadget, leave a comment and I will excite you.

+7
javascript jquery null google-wave
source share

No one has answered this question yet.

See related questions:

5129
How to return a response from an asynchronous call?
3805
Avoidance! = Null
2812
event.preventDefault () vs. return false
2597
How to check empty string / undefined / null in JavaScript?
2038
Is there a standard function for checking null, undefined or empty variables in JavaScript?
1957
How to determine if a variable is "undefined" or "null"?
1187
Do I need a null check before calling instanceof?
1134
Column change: from zero to non-empty
996
What is the difference between null and undefined in JavaScript?
891
null object in python?

All Articles