Last active
September 30, 2015 14:53
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
onClickDiscuss MouseEvent {} | |
Helpers.js:9 onClickDiscuss Object {row: 1443624671207, column: "discuss"} | |
Helpers.js:11 /posts/1443624671207 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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); | |
}; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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