Questions tagged [evently]

Evently is a jQuery plugin for writing event-based applications.

Evently is a jQuery plugin for writing event-based applications. Bsically it uses an object notation to group events related to a same DOM node, making the code cleaner and more maintainable. Evently was thought as a tool to make CouchDB application development simpler, but you can use it for any project where you could use jQuery.

Let's take a look to a simple example from the Evently primer.

In jQuery you have to repeat yourself when you attach different event listener to a DOM node:

$("#myelement").bind("click", function() {
  $(this).text("You clicked me.");
});

$("#myelement").bind("mouseenter", function() {
  $(this).text("You moused over me.");
});

$("#myelement").bind("loggedIn", function(e, user) {
  $(this).text("You are logged in.");
});

Evently use a single object instead:

$("#myelement").evently({
  click : function() {
    $(this).text("You clicked me.");
  },
  mouseenter : function() {
    $(this).text("You moused over me.");
  },
  loggedIn : function() {
    $(this).text("You are logged in.");
  }
});

Evently has more interesting features. From the primer:

1) Evently has a built-in way to handle Ajax calls and Mustache templating.

2) Evently widgets can contain other Evently widgets, nested like matryoshka dolls. This turns out to be hella useful.

3) Evently has some magic events, including a handler for realtime updates from CouchDB.

4) Evently code can be represented as a deeply-nested filesystem tree, when you use the CouchApp script to deploy it.

For more information on this plugin,

8 questions
2
votes
1 answer

Why does evently suggest $$(this) to save state?

As explained here, to save state which must be accessible in different events, $$(this) is recommended, like this: $$(this).filters = "myvalue"; What does that syntax mean? Why $$ (double dollar)? Why this? Why the () (parentheses)? That code is…
blueFast
  • 41,341
  • 63
  • 198
  • 344
1
vote
1 answer

How do I save an updated CouchDB doc with Evently?

I'm following IBM's tutorial on CouchDB and ran into a problem saving edited documents. Saving a new doc works fine, and it looks like all my existing doc's values (retrieved via the openDoc function) are valid, but the new values are simply not…
Matt Norris
  • 8,596
  • 14
  • 59
  • 90
1
vote
0 answers

Problems accessing object member in javascript

In a _changes/data.js file I have the following implementation: function(data) { var p; var tmp = $$("#profile"); $.log(tmp); $.log(tmp.profile); if (undefined != tmp.profile) { return { cdrs :…
blueFast
  • 41,341
  • 63
  • 198
  • 344
1
vote
2 answers

Event listeners for dynamic content in evently

I am generating a dynamic html table. One of the columns in the table has a clickable image (a href). For testing, I have also created a static table, with similar structure as the dynamic table, in the same div. I have defined a…
blueFast
  • 41,341
  • 63
  • 198
  • 344
1
vote
1 answer

Evently events stop being triggered after page reload

I have a couchapp based on evently. When I push the couchapp and start browsing it, it works fine. But as soon as I reload the page, the events stop being generated: in this case click events on an a href. The most confusing thing about this is that…
blueFast
  • 41,341
  • 63
  • 198
  • 344
1
vote
1 answer

Handling two submit buttons with evently

I have a form with two submit buttons:
...
Depending on which button I click, I must do two different things.…
blueFast
  • 41,341
  • 63
  • 198
  • 344
0
votes
1 answer

couchapp+evently: _init/data.js and $$(this)

I'm reading the couchapp tutorial http://couchapp.org/page/evently-do-it-yourself-ii-state and am confused on two points (I don't like being told answers without knowing why they are what they are): $ cat data.js function(e) { $$(this).toppings =…
Jason S
  • 184,598
  • 164
  • 608
  • 970
0
votes
2 answers

What are all the methods of $.couch that CouchApp simplifies?

Based on screencasts and tutorials across the web, I realized that when compared to fetching data like this: $.couch.db("addressbook").view("addressbook/phonenumbers", { success: function(data) { for (i in data.rows) { id =…
pulkitsinghal
  • 3,855
  • 13
  • 45
  • 84