Example: Online Poll


Demonstrates an online polling system for logged in users, thus allowing only one vote per user. Shows the results with an options for showing results even if the user hasn’t voted yet. Also has an option for allowing/preventing the user from changing their vote.

The example template has a very basic (and incomplete) admin functionality allowing for creating and editing polls.

And yes, since you mentioned it, there are a few loose ends. This is really just an example. I stopped as I got precipitously close to falling off the cliff of “full blown app”.

Have fun!

Go to the Online Poll page.

See more examples at The Brewmaster’s website .

2 Likes

@yisrael-wix , why did you define the $w.onReady() itself as async function? Wouldn’t it work the same without that? (sorry if my question is stupid…)

Good point. When I was developing this example, I used database queries with await in the onReady() function - and therefore I needed aync because of the await . After things were working, I moved the queries to functions in the backend where they belong. I just forgot to remove async from the onReady() statement. I’ll fix it when I get a chance. Thanks! :beers:

I see. Thanks. And may I ask what’s the benefit of moving these queries functions to the backend? Does it have any effect on the performance somehow?

The main issue is security. It’s best to hide sensitive code and information (such as API keys, user IDs, special propietary code, etc) from prying eyes. Users can see front end code, but backend code is isolated on the server away from view.

Thanks!