Title: Gridstack on Meteor · Issue #77 · gridstack/gridstack.js · GitHub
Open Graph Title: Gridstack on Meteor · Issue #77 · gridstack/gridstack.js
X Title: Gridstack on Meteor · Issue #77 · gridstack/gridstack.js
Description: Hi @troolee, Thx for this library! Totally awesome. I just worked out how to use gridstack on Meteor. I have implemented persistent edits, which stores the grid tile properties in a Mongo collection. I have to say, it's pretty cool! Belo...
Open Graph Description: Hi @troolee, Thx for this library! Totally awesome. I just worked out how to use gridstack on Meteor. I have implemented persistent edits, which stores the grid tile properties in a Mongo collectio...
X Description: Hi @troolee, Thx for this library! Totally awesome. I just worked out how to use gridstack on Meteor. I have implemented persistent edits, which stores the grid tile properties in a Mongo collectio...
Opengraph URL: https://github.com/gridstack/gridstack.js/issues/77
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Gridstack on Meteor","articleBody":"Hi @troolee,\nThx for this library! Totally awesome.\nI just worked out how to use gridstack on Meteor. I have implemented persistent edits, which stores the grid tile properties in a Mongo collection. I have to say, it's pretty cool!\n\nBelow is the code I've used. \n\nAdd existing smart package from atmospherejs.com (https://atmospherejs.com/tarzak/gridstackjs) -- I'm trying to find out if the author will publish their package code onto GitHub.\n\n```\nmeteor create myApp\ncd myApp\nmeteor add tarzak:gridstackjs\n```\n\nHTML:\n\n``` html\n\u003c!-- myApp.html --\u003e\n\u003cbody\u003e\n{{\u003e gridstack}}\n\u003c/body\u003e\n\u003ctemplate name=\"gridstack\"\u003e\n \u003cdiv class=\"grid-stack\"\u003e\u003c/div\u003e\n\u003c/template\u003e\n```\n\nShared client/server JavaScript to create a Mongo collection\n\n``` javascript\n// myApp.js\nGridTiles = new Mongo.Collection(\"gridTiles\");\n/* GridTiles.insert({\n _id: \"abcd\", // mongoId \n x: 0,\n y: 1,\n width: 2,\n height: 2\n}); */\n```\n\nClient JavaScript\n\n``` javascript\n// client/myGridstack.js\nTemplate.gridstack.rendered = function () {\n var gridstackOptions = {};\n Tracker.autorun(function () {\n var gridTiles = GridTiles.find().fetch();\n var grid = $('.grid-stack').gridstack(gridstackOptions).data('gridstack');\n grid.remove_all();\n _.each(gridTiles, function (tile) {\n var widgetElement = $('\u003cdiv\u003e\u003cdiv class=\"grid-stack-item-content\" /\u003e\u003cdiv/\u003e')\n if(widgetElement) {\n grid.add_widget(widgetElement, tile.x, tile.y, tile.width, tile.height);\n widgetElement.attr('data-custom-id', tile._id);\n }\n });\n }); // End autorun\n // Define onchange to update Mongo collection\n $('.grid-stack').on('change', function (event, items) {\n _.each(items, function (item) {\n var attributes = item.el.data();\n GridTiles.update({_id:attributes.customId},\n {x:attributes.gsX,y:attributes.gsY,height:attributes.gsHeight, width:attributes.gsWidth});\n });\n });\n}; \n```\n\nThat's it! =-) \nNew tiles can be added on the fly (i.e., reactively) just by inserting into the Mongo collection. When you move or resize the tiles, the new locations are saved. The \"bindings\" are already hooked up because of the `Tracker.autorun()` function.\n\nThe Meteor community is building procedures for libraries like Gridstack.js to have \"official\" integrations with Meteor (i.e., sponsored by the official maintainers). If you're open to this, I can try to help with the set-up as well as add documentation.\n","author":{"url":"https://github.com/jonlachlan","@type":"Person","name":"jonlachlan"},"datePublished":"2015-02-25T20:02:34.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":12},"url":"https://github.com/77/gridstack.js/issues/77"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:2ee71331-82dd-fd95-5d7e-cbc2733e4a22 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A156:1E98B7:7E0FD2:A6517E:69783492 |
| html-safe-nonce | 84ef9630d3121bf3dfe172ae0d924f2243a8c54cbdd4fbb6069657d017031cd1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMTU2OjFFOThCNzo3RTBGRDI6QTY1MTdFOjY5NzgzNDkyIiwidmlzaXRvcl9pZCI6IjU5MjYyNjA5MTk3NzUwMTYwODIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 3af87b87a62c39cf311f03b42ce8b09a42ae1d0c67e0d36cfbba14d662f136de |
| hovercard-subject-tag | issue:58960759 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/gridstack/gridstack.js/77/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7342ba5479aae89dba7c3465f8dd6d39faba82dc9322e09fc7b442a9ba863074/gridstack/gridstack.js/issues/77 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7342ba5479aae89dba7c3465f8dd6d39faba82dc9322e09fc7b442a9ba863074/gridstack/gridstack.js/issues/77 |
| og:image:alt | Hi @troolee, Thx for this library! Totally awesome. I just worked out how to use gridstack on Meteor. I have implemented persistent edits, which stores the grid tile properties in a Mongo collectio... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jonlachlan |
| hostname | github.com |
| expected-hostname | github.com |
| None | 2981c597c945c1d90ac6fa355ce7929b2f413dfe7872ca5c435ee53a24a1de50 |
| turbo-cache-control | no-preview |
| go-import | github.com/gridstack/gridstack.js git https://github.com/gridstack/gridstack.js.git |
| octolytics-dimension-user_id | 31674162 |
| octolytics-dimension-user_login | gridstack |
| octolytics-dimension-repository_id | 26417283 |
| octolytics-dimension-repository_nwo | gridstack/gridstack.js |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 26417283 |
| octolytics-dimension-repository_network_root_nwo | gridstack/gridstack.js |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8cc3e064910e26648760f573a358cfc07c97b42c |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width