Skip to content

Instantly share code, notes, and snippets.

@bartonhammond
Last active September 30, 2015 14:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bartonhammond/fc2727c76eea6e23ae16 to your computer and use it in GitHub Desktop.
Save bartonhammond/fc2727c76eea6e23ae16 to your computer and use it in GitHub Desktop.
Meteor Webix Datatable onClick event. posts_list.html has column w/ 'fa-comment-o' icon. datatable has <config> with 'onClick' and function provided by helper
onClickDiscuss MouseEvent {}
Helpers.js:9 onClickDiscuss Object {row: 1443624671207, column: "discuss"}
Helpers.js:11 /posts/1443624671207
'use strict';
(function(globals){
"use strict";
globals.Helpers = {};
}(this));
Helpers['onClickDiscuss'] = function(ev, id) {
console.log('onClickDiscuss', ev);
console.log('onClickDiscuss', id);
var path= Router.routes['postPage'].path({_id: id});
console.log(path);
};
<template name="postslist">
<div data-id="postslist"
data-view="datatable"
data-type="line"
data-autoheight=1>
<config name="onClick" fa-comment-o="{{onClick}}"></config>
<div data-view="column"
data-fillspace=1
data-id="title">
Title
</div>
<div data-view="column"
data-fillspace=1
data-id="url">
URL
</div>
<div data-view="column"
data-template="<span style='cursor:pointer; text-align:center' class='webix_icon fa-comment-o'></span>"
data-id="discuss">
Discuss
</div>
<ul data-view="data">
{{#each posts}}
{{> postItem}}
{{/each}}
</ul>
</div>
</template>
'use strict';
Template.postslist.onRendered(function() {
if (_.isUndefined(webix.ui.views['postslist'])) {
var component = webix.markup.init();
webix.event(window, 'resize', function(){
if (component) component.resize();
});
}
});
Template.postslist.onDestroyed(function() {
if (webix.ui.views['postslist']) {
webix.ui.views['postslist'].destructor();
}
});
Template.postslist.helpers({
posts: function() {
return Posts.find();
},
onClick: function() {
return "Helpers.onClickDiscuss";
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment