Created
September 30, 2015 05:06
-
-
Save bartonhammond/3f2c583a9f807d5ecb93 to your computer and use it in GitHub Desktop.
Meteor Webix Datatable - my desire is o click icon in row of datatable and call a function where the row is known so I can do something w/ that data.
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="postItem"> | |
<li data-title="{{title}}" | |
data-url='<a href="{{url}}" target="_blank">{{url}}</a>' | |
> | |
</li> | |
</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
Template.postItem.helpers({ | |
title: function() { | |
return this.title; | |
}, | |
url: function() { | |
return this.url; | |
} | |
}) |
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"> | |
<!-- I'm looking for design pattern when 'webix-icon is clicked to call function name 'discuss' shown in | |
posts_list.js below | |
--> | |
<div data-i | |
data-view="datatable" | |
data-type="line" | |
data-onClick='webix-icon: '{{discuss}}' | |
data-autoheight=1> | |
<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(); | |
}, | |
/** | |
* I want to have some function like this to execute when the webix-icon on that row is clicked' | |
*/ | |
discuss: function() { | |
return ` | |
return Router.routes['postPage'].path({_id: this._id}); | |
` | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment