01-24-2022 19:42
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

01-24-2022 19:42
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Hello,
I am trying to update my grading app to OS6.0, but I am having difficulty.
I can implement the new views, but when I try to move the grade settings spinner from index.js to a new view page (using the single.js as a template from the sdk-app-demo), I get the following error.
Unhandled exception: TypeError: Cannot read property 'addEventListener' of null
The spinner works well on its own, and I can get the views to work, but they are not working together. Does anyone have any ideas about what I am doing wrong?
01-24-2022 23:14
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


01-24-2022 23:14
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
@LekoFraggle - couldn't get some of the examples in the API documentation to work in SDK 6.0, so went back to 5.0 and they work. Didn't investigate further.
SDK 6.0 may need different coding examples as yet to be provided.
Author | ch, passion for improvement.

01-25-2022 03:47
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

01-25-2022 03:47
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Thank you,
Can you direct me toward any version of the new views documentation that shows how to create one in 6.0 that also supports an event listener for a tumbler? I believe checkboxes worked, so there may be something other than just the eventlistener awry.

01-25-2022 04:30
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


01-25-2022 04:30
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
@LekoFraggle - maybe @Gondwana can.
Author | ch, passion for improvement.

01-25-2022 19:26
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

01-25-2022 19:26
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
Thank you. So, I tried a button, and it does not work either. So, until I can figure this out, I am without any of my apps. All of them rely upon multiple windows and event listeners.
01-25-2022 20:01
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


01-25-2022 20:01
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
@LekoFraggle - have you tried in SDK 5.0 instead unless you need SDK 6.0?
Author | ch, passion for improvement.

01-25-2022 20:20
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

01-25-2022 20:20
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
So, I think I need 6.0. My watch is currently running it. Even if I could roll it back, I do not think you can prevent it from updating. I do use the weather app too. Besides, just use an old SDK is not something a developer should have to tell their clients ever.
I have only released one of my apps, but was going to release more now that I have the new device to test. Yet, I cannot even update the old app successfully.
01-25-2022 20:25
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


01-25-2022 20:25
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
The watch will usually run software that targets an earlier SDK (>=5).
I'd be investigating which variable (or returned value) is null, and trying to work out why.
SDK5+ does deregister some things when views are changed, but I don't think that behaviour differs between SDK5 and SDK6.
Gondwana Software

01-25-2022 20:50
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


01-25-2022 20:50
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
@LekoFraggle - what @Gondwana says. Watches are generally backwards compatible, clocks or apps are not, so you can use SDK 5.0 without a problem.
A common code problem can be
Document Variable = "text";
Instead of
Document Variable.text = "text";
Or multiple definitions.
let Variable = 0;
Document Variable.text = "text";
And sometimes where the error is indicated is not where the error actually is.
Might help
Author | ch, passion for improvement.

01-26-2022 03:38
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

01-26-2022 03:38
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
Hello,
Thank you. If it were either of those issues, it would not work in 5.0 either, correct?
I am pretty certain that this is working in 5.0.
01-26-2022 04:47
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


01-26-2022 04:47
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
@LekoFraggle- correct. What works in 5 should work in 6.
Any coding differences should be identified somewhere in the documentation, it may not have been updated yet.
Author | ch, passion for improvement.

01-26-2022 16:09
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

01-26-2022 16:09
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
I figured it out. Though I have not tried with a tumbler yet, I can explain what had happened (and how it probably was not working in 5.0 either).
Because of how the error presented, I assumed that both views(index and our view) needed to at least be aware of the object that the event listener is running in (otherwise it instantly fails, which is what was happening.)
I dug deeper into the sample app.
It has a Cycle view which uses buttons. I noticed that the fix was easy. They put the EventListener() in the exported update method. They also directly accessed the object rather than constructing a local variable that the index method cannot access (I am not sure if this is correct, but seems plausible).
Here is how it worked for me...
export function update() {
document.getElementById("myButton").addEventListener("click", (evt) => {
console.log("You just CLICKED a button!!!");
})
}
Anyway, thank you for your help, guidance, and patience. As always, it was totally operator error.
Also, as far as documentation for the new views, I found that as well. They are documented here (which was in the blog post)
.
01-26-2022 16:23
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


01-26-2022 16:23
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
Thanks for the info.
It's just possible that addEventListener works in that context because document-related object get nuked when the view is changed. It should be possible and safe to re-establish event listeners in the view-changing promise resolution block.
Gondwana Software
