coffeescript

Login not working in Firefox in Meteor

﹥>﹥吖頭↗ 提交于 2019-12-12 17:36:08
问题 I am trying to develop the login functionality in meteor, and I am using jade-handlebars and coffeescript. My coffeescript page: Template.navigation.events "submit #login-form": (e, t) -> e.preventDefault() if Meteor.userId() Meteor.logout() else # retrieve the input field values email = t.find("#login-email").value password = t.find("#login-password").value # If validation passes, supply the appropriate fields to the # Meteor.loginWithPassword() function. Meteor.loginWithPassword email,

what is the correct way to use coffeescript with ember´s Mixins?

只愿长相守 提交于 2019-12-12 17:01:10
问题 Apologies for my english, I am trying to extend a View with a mixin. The code is coffeescript : View - films_film_view.js.coffee App.FilmsFilmView = Em.View.extend App.ModalViewMixin, templateName: 'films/show' Mixin - modal_view_mixin.js.coffee App.ModalViewMixin = Em.Mixin.create modalView: null click: -> @showModalView() close: -> @closeModalView() closeModalView: -> if @modalView @modalView.close() showModalView: -> @closeModalView() @modalView = @createModalView() if @modalView

backbone.js save with coffeescript

眉间皱痕 提交于 2019-12-12 16:19:52
问题 I have the following method on a backbone view defined in coffeescript: saveObservation: => self = @ observation = new Observation(ParentUid: _questionUid, Status: "N/a", Text: "Change to element") observation.save { success: -> alert('test') error: -> alert('failed') } Observation is extended from Backbone.Model class Observation extends Backbone.Model url: -> "/AuditActionTracking/" The save reaches the server but neither the success nor the error handlers I have defined in the save are

CoffeeScript idiom for Array.reduce with default value

泪湿孤枕 提交于 2019-12-12 16:19:41
问题 In CoffeeScript sometimes I need to call Array.reduce(...) with a default value; however, the unfortunate ordering of the arguments means the initial/default value goes after the reduce function itself, which means I've got to use a lot of parens, which seems much uglier than CoffeeScript wants to be. For example: items = [ (id:'id1', name:'Foo'), (id:'id2', name:'Bar') ] # ... itemsById = items.reduce(((memo, item) -> # <-- Too many parens! memo[item.id] = item memo), {}) # Ugly! Is there a

Catch all events except in reset

若如初见. 提交于 2019-12-12 16:05:49
问题 I wanna catch all events except 'reset'. I've a code like this initialized inside a View. messagesCollection.on 'all', @_handleMessageChanges, @ Right now it works for all events. As I've mentioned above I don't need to catch in a reset event. How can I resolve this issue? Please help us. 回答1: When using all , the first argument is the event . So, you can do _handleMessageChanges: function(event, ...) { if ( event === 'reset' ) return; } See it in action here: http://jsfiddle.net/nxs9q/1 From

What is Dynamic Code Evaluation as mentioned by John Resig

佐手、 提交于 2019-12-12 15:49:38
问题 In his book "Secrets of the Javascript Ninja", John Resig writes: Although dynamic code evaluation has been maligned due to its complexity and potential for security issues, without it we wouldn’t have had the CoffeeScript programming language. I was hoping that someone could explain what is Dynamic Code Evaluation? Also, are there any code examples (or word examples) that would help better explain it? Furthermore, are there any website examples that use dynamic code evaluation? Also, if

Weird deployment issue with Django and CoffeeScript to Heroku

删除回忆录丶 提交于 2019-12-12 12:15:20
问题 This is sort of a complex question so it will take a bit to explain. I'm not looking for a direct answer so any advice would be good. I have a Django app that uses a lot of CoffeeScript. To compile the CoffeeScript in the project I am using the app django-compressor . To use django-compressor I need to install nmp (node package manager). Unfortunately, I can't install npm on Heroku. Thus, I need to compile the CoffeeScript before it hits the Heroku servers. So I did that by setting up Fabric

Get rails view helper methods inside coffeescript

落花浮王杯 提交于 2019-12-12 11:22:07
问题 I have a view helper, let say (for simplicity's sake) def call_alert return "alert 'this should appear'" end Then I have a coffeescript file some_test_page.js.coffee which renders for an action which is called via ajax. Inside this some_test_page.js.coffee I have: <%= call_alert %> When I do an ajax call to /some_test_page , I usually would expect to get a response with the compiled javascript from the coffeescript file and an alert would occur. However, it seems the view helper I tried to

Binding click event in jquery coffeescript

吃可爱长大的小学妹 提交于 2019-12-12 11:13:16
问题 I am working on rails 3.2 and using coffeescript too.. I have a doubt in using jquery mobile inside my application I have a html like <a href="#" data-item=12 data-status=true class="follow"> <span class="ui-btn-inner"> <span class="ui-btn-text"> Follow </span> </span> </a> In my coffeescript, i am trying to write function on click of this Follow, i am trying to send a ajax call. when i wrote like $("a.follow").unbind('click').bind 'click', (event, data) -> event.stopPropagation() clickedEl =

'effect' works fine in jsfiddle but not in live code ([object Object] has no method 'effect' )

你。 提交于 2019-12-12 10:38:02
问题 Related, but not a fix: jQuery issue - #<an Object> has no method I'm getting an error Object [object Object] has no method 'effect' when I try to use the effect function in jquery (doc http://docs.jquery.com/UI/Effects/Highlight). It's working fine in JSFiddle but it errors out when I run the site in Chrome or IE. The div gets shown but the effect call throws an error. Live version can be found here: http://jsfiddle.net/jcollum/HK625/ Html <a id=showHowThisWorks >How does this all work?</a>