Multiple instabilities in project

Hi!

So I’m working on this app, and it seems that I’ve now gotten to the point where I have multiple breaking bugs that don’t allow me to move forward.

Problem 1
When starting the app, you press login. If the login succeeds (default user/password is correct) you will be transfered to the screen where you can vote. As far as I’ve seen, this screen is always blank (Except for the top bar). Even if the JSON is loaded (log-output on Vote.js#36).
Restarting the app-preview by saving a file seems to fix this. I guess it’s the <Each> in VoteView.ux#71 that’s causing the problem.

Problem 2
When you restart the app-preview and the Voteview has entries, the loading text which is defined as an observable in vote.js#9 and used in VoteView.ux#19 won’t change from “loading” to empty-string.

Problem 3
When you restart the app-preview and the Voteview has entries, you can click/tap an image to get the opportunity to vote. This behaves like numbers sliding down from the image. When you click a number, almost always the application crashes with a complaint about a missing callback.
This is kind of weird as the vote function on vote.js#66 almost always outputs “I voted!” from vote.js#87. I can also see that the vote is registered in the database.

Project for testing

If you want to check out the database it’s stored on http://178.62.60.204:3000

I guess that some of the problems is caused by bad code and lack of understanding how Fuse works, if so I am eager to learn :slight_smile:

  1. The problem is that you have two javascripts in your UX. The way this works with bindings to the UX is that one of these is your default data-context. Now you only get the last one. If you concat these javascripts this works well for me. Other solutions include making one of them a library and load via ux:Global and require, or make a separate UX file that can have one of the javascripts.

Actually just having one javascript makes your app behave pretty diffrent. Try it out, and check if it maybe solves all your problems. :slight_smile:

  1. The problem is that you have two javascripts in your UX. The way this works with bindings to the UX is that one of these is your default data-context. Now you only get the last one. If you concat these javascripts this works well for me. Other solutions include making one of them a library and load via ux:Global and require, or make a separate UX file that can have one of the javascripts.

Actually just having one javascript makes your app behave pretty diffrent. Try it out, and check if it maybe solves all your problems. :slight_smile:

That actually solved all the problems. Kind of unexpected, but it makes sense if it works like you describe :slight_smile:

Though I hate doing all my code in one file, as it feels seriously messy, and these aren’t the last js-files I’ll make. I guess concating all the javascript with for instance gulp is something I could do as a solution. How would I go around creating a library and loading with ux:Global?

To make the library available:

<JavaScript File="lib.js" ux:Global="lib" />

To access it from JS:

var lib = require('lib');

And to export it to UX:

module.exports = {
  something: lib.something
}

or even

module.exports = {
 lib: lib
}

Thanks a lot! :slight_smile: