coffeescript

AngularJS, multiple draggable items causes 'jump' on initial move

只谈情不闲聊 提交于 2019-12-12 10:26:56
问题 I am using the example code located on the AngularJS main site. When I move the first draggable object, all is well. As soon as I begin dragging a second object, the second object 'jumps' exactly the distance which the first object was moved. Initially I thought the fix would be as simple as resetting the variables. Unfortunately, all of my attempts have caused 'indentation errors'. # Angular Drag Components RE-uses vars from previous drag, bugging out the dragging angular.module("aehalo", []

Backbone not binding events to jQuery Popover

给你一囗甜甜゛ 提交于 2019-12-12 10:11:38
问题 This question seems similar to those asked in a few other posts: here and here. I feel like I understand the concept, but I'm still having issues. I am using the Twitter Bootstrap stuff for javascript popovers; the popover is where I want to bind events. The Bootstrap javascript inserts/removes the html each time you call .popover('show')/.popover('hide'). The events that are bound to the html inside of the popover do not get called. From what I read, Backbone uses jQuery.delegate() so it

Error: Unknown provider: aProvider <- a

旧巷老猫 提交于 2019-12-12 08:47:47
问题 I'm using AngularJS in a Ruby on Rails 3.2.8 project with assets. When I load up my form which is using AngularJS on my development machine I don't have a problem. However when I load the same form up on my production server I get this error in the Javascript console: Error: Unknown provider: aProvider <- a I've tracked it back to my coffeescript file where I setup AngularJS for use within a form: $ (event) -> $("#timesheet_description").autocomplete({source: '/autocomplete/work_descs'}) #

CoffeeScript to select form fields dynamically on change and on load

陌路散爱 提交于 2019-12-12 08:12:31
问题 I have a Rails app where I'm trying to select a list of facilities based on what region is selected in a form. So far, I've implemented group_collection_select to do this as well as a bit of CoffeeScript. It works when creating a new record and selecting a region. The behavior being to only show facilities listed for the selected region. What does not work is when editing a record, selecting the facilities shows all of the facilities grouped by region instead of constraining the facilities to

Resolving circular dependencies with Node.js require and classes in CoffeeScript

时光毁灭记忆、已成空白 提交于 2019-12-12 07:52:10
问题 I want to know if there is a way to idiomatically avoid issues with circular dependencies with Node.js's require while using CoffeeScript classes and super . Given the following simplified CoffeeScript files: a.coffee: C = require './c' B = require './b' class A extends C b: B someMethod: -> super module.exports = A b.coffee: C = require './c' A = require './a' class B extends C a: A someMethod: -> super module.exports = B The first obvious issue here is that there is a circular dependency

CoffeeScript: How to use both fat arrow and this?

我是研究僧i 提交于 2019-12-12 07:09:26
问题 I have a coffeescript class that has some jquery event listeners. I would like to use the fat arrow => to avoid having to reference the class, but I still need a reference to the element that would usually be used with this . How can I use both? class PostForm constructor: -> $('ul.tabs li').on 'click', => tab = $(this) @highlight_tab(tab) @set_post_type(tab.attr('data-id')) highlight_tab: (tab)-> tab.addClass 'active' set_post_type: (id) -> $('#post_type_id').val(id) 回答1: CoffeeScript links

Ruby on Rails asset pipeline doesn't work properly

元气小坏坏 提交于 2019-12-12 06:15:27
问题 I have been working on a ruby on rails project just now. I have created a controller named 'animals' and a view (index.html.erb) for index action. I don't want to include 'application' javascript file. So I created animals.js The file's content is //= require jquery //= require jquery_ujs //= require turbolinks //= require bootstrap-sprockets //= animals.coffee I have also added animals.js and animals.css to asset.rb Rails.application.config.assets.precompile += %w( animals.js ) Rails

Call coffeescript function from jQuery function

倖福魔咒の 提交于 2019-12-12 05:42:36
问题 I have two files: first one is a plain jQuery, and a second one is a Coffeescript jQuery file: $(document).ready(function(){ checkPrice(); }); CoffeeScript file: $ -> checkPrice = -> alert("OK"); I get following error: "Unhandled Error: Undefined variable: checkPrice" In the template they are included in opposite direction: coffeescript file, then jquery file. Is there some way to make them working together ? 回答1: OK. Got it. checkPrice should have been declared as global, so in coffeescript

Scoping issue with callbacks in coffeescript

心已入冬 提交于 2019-12-12 05:18:15
问题 I'm really new to Coffeescript/Javascript and I'm writing a little package for Atom. I have no idea why the create_dir function is not visible to the inner function. I suspect there is some kind of scoping problem going on, {CompositeDisposable, Directory, File} = require 'atom' module.exports = ImageAssistant = subscriptions: null activate: (state) -> # Events subscribed to in atom's system can be easily cleaned up # with a CompositeDisposable @subscriptions = new CompositeDisposable #

Unable to make auto focus on fields for bootstrap modal

不想你离开。 提交于 2019-12-12 05:11:49
问题 Hi so following this rails tutorial using coffeescript , a part of this function is suppose to find the bootstrap div modal, then find the "textarea" within it to auto focus it immediately . ready = -> $(".media").on "click", -> document.location = $(this).data("target") return false $(".modal").on "shown.bs.modal", -> $(this).find("textarea").focus() $(document).ready(ready) $(document).on "page:load", ready The .media function click is working so far. However, another function which uses