Skip to main content

Posts

Showing posts with the label coffeescript

CoffeeScript-like language written in Python

Are there any languages targeting JavaScript (like CoffeeScript) and written in Python? I found Pyjamas , but it’s GWT of Python as I see. I want a language that doesn’t need heavy runtime library and is able to be compiled to JavaScript. I found Mascara also, and it very satisfies my requirements except it’s license. CoffeeScript is ideal for me except it’s written in CoffeeScript itself. I have to compile [CoffeeScript-like language] source codes into JavaScript statically in Python application.

require()"ing a CoffeeScript file from a JavaScript file or REPL

I'm using Node.js and wanting to incorporate CoffeeScript into my workflow. I have two use-cases: I want to be able to write JavaScript files which require() CoffeeScript modules I want to be able to load CoffeeScript modules from within the node REPL For case #1 I can just compile from .coffee to .js and require() the .js module, as a workaround. For case #2 right now I'm eval()'ing the output of coffee-script.compile(). Is there a better, more unified way to do this? Source: Tips4all

Class Pointers in CoffeeScript?

trying to figure out how to write the following in CoffeeScript: var foo = new function() { var $this = this; $("#foo").click( this.clicked ); this.clicked = function() { $this.alert( $(this).text() ); }; this.alert = function(message) { alert(message); }; }; Unfortunately I can't figure out for the life of me how in CoffeeScript I access the class pointer, "this" is obviously not context aware and will often just point to the variable passed by the callee. So there's no way for me to write the above script in CoffeeScript. Any advice? I can't find anything useful in the documentation, you have the @ pointers but they also just use the "this" pointer from the current context, making it useless..

Using bootstrap-modal as Backbone.js view

I am attempting to create a Backbone.js view based on a Twitter bootstrap-modal, which makes use of Backbone's automatic event delegation via the events attribute of the view. Unfortunately, bootstrap-modal seems to break Backbone's event delegation as it clones the view HTML before displaying the modal: that.$element .appendTo(document.body) .show() My view: App.Views.ProjectsNav ||= {} class App.Views.ProjectsNav.NewProjectView extends Backbone.View events: { 'click .save': 'save', 'shown': 'shown' } save: (e) -> ... false shown: () -> App.Helpers.Forms.setFocus($(@el), true) false render: () -> $(@el).html(ich.nav_edit_project_template(@model.toJSON())) @$('.modal').modal({'show': true, 'keyboard': true, 'backdrop': true}) @ The corresponding (Mustache) HTML template: <div class="modal hide" style="display: none;

Using bootstrap-modal as Backbone.js view

I am attempting to create a Backbone.js view based on a Twitter bootstrap-modal, which makes use of Backbone's automatic event delegation via the events attribute of the view. Unfortunately, bootstrap-modal seems to break Backbone's event delegation as it clones the view HTML before displaying the modal: that.$element .appendTo(document.body) .show() My view: App.Views.ProjectsNav ||= {} class App.Views.ProjectsNav.NewProjectView extends Backbone.View events: { 'click .save': 'save', 'shown': 'shown' } save: (e) -> ... false shown: () -> App.Helpers.Forms.setFocus($(@el), true) false render: () -> $(@el).html(ich.nav_edit_project_template(@model.toJSON())) @$('.modal').modal({'show': true, 'keyboard': true, 'backdrop': true}) @ The corresponding (Mustache) HTML template: <div class="modal hide" style="display: none;