coffeescript

endless scrolling does not work

时间秒杀一切 提交于 2019-12-12 00:51:24
问题 Update: My Github Repository https://github.com/Marc585/smartforce2 i just finished the onemonthrails tutorial. at the last chapter its about endless scrolling. i tripple checked my code but it just doesn't work. I don't get an error or anything. It just doesn't do anything. I'm building a pinterest clone and after i scroll to the bottom it should load the next page of pins. This is my pins.js.coffee # Place all the behaviors and hooks related to the matching controller here. # All this logic

Can you extend initialized models?

馋奶兔 提交于 2019-12-12 00:33:38
问题 class TheModel extends Backbone.Model foo: #bar Entity = new TheModel(#pass in attributes) Can I then extend Entity and maintain the models attributes/state? class User extends Entity foo: super #more EDIT: class Entity extends Backbone.Model initialize: (options) -> @_events options _events: (options) -> entity.bind 'foo' class Entity1 extends Entity _events: (options) -> super options entity.bind 'bar' class Entity2 extends Entity _events: (options) -> super options entity.bind 'baz' #a new

React onClick event is not fired when element is created in for loop

ぐ巨炮叔叔 提交于 2019-12-11 23:54:59
问题 I was trying to solve this strange problem all day, but didn't managed to. This is one of the first days I am trying out React, so maybe I am missing something. ParentComponent.cjsx module.exports = React.createClass getInitialState: -> { items: [] } componentDidMount: -> request.get(constants.API_ROOT + @props.source) .end((err, res) => @setState({items: res.body}) ) render: -> ` // First try: DOES NOT WORK var items = []; for(var i = 0; i < this.state.items.length; i++) { var item = this

Events for fs createReadStream Not Always Being Called

試著忘記壹切 提交于 2019-12-11 23:19:52
问题 I have an fs filestream being used to serve file downloads which are dynamically created. I get this stream and pipe it to my response object after setting appropriate headers. I also set a couple stream events so that if there's an error or the stream ends, it removes the generated files from the file system. I'm running into an issue where, on occasion, when the download isn't correctly initialized or finished there may be some hanging files left on the file system. I believe this is

Coffeescript .bind seems to be wrapped inside a function when compiled to js and is not called

久未见 提交于 2019-12-11 22:56:56
问题 I am trying to use a flot in a coffeescript .The returned javascript wraps all the methods in a function call and because of that I am not able to use the .bind event. $(this).bind 'plothover', (event, pos, item) -> is not getting called when my mouse moves $ -> $("#flot-placeholder1").text("Amit") plot = $.plot($("#flot-placeholder1"), dataset, options) $("#flot-placeholder1").UseTooltip() $.fn.UseTooltip = -> alert "UseTooltip" **$(this).bind 'plothover', (event, pos, item) ->** alert

Using wait.for with nodejs and mongoskin to avoid callback hell

≡放荡痞女 提交于 2019-12-11 22:37:14
问题 I m actually developping a little application with mongodb and nodejs to create my REST Api. I face a problem when I need to access an object reference : I have a roadmap collection which reference a user object When I want to get all the roadmaps, I have to loop on my roadmap array to lazy load my users, by the ref ID stored in the roadmap collection I have a callback problem, the user is not loaded when I need it I have found a solution using Wait.for library : https://github.com/luciotato

AngularJS: app not getting data from get request

烂漫一生 提交于 2019-12-11 22:36:01
问题 My Angular app has the following code: index.jade: doctype 5 html head body(ng-app='app') div(ng-controller='EventController') div(ng-repeat='event in events') h2 {{event.name}} h3 {{event.location}} h2 Create new event label(for='name') Name: input(ng-model='event.name') label(for='location') Location: input(ng-model='event.location') button(ng-click='create(event)') Submit script(src='https://ajax.googleapis.com/ajax/libs/angularjs/1.1.5/angular.js') script(src='https://ajax.googleapis.com

Rails4: “scrollTop” doesn't work every other click

China☆狼群 提交于 2019-12-11 22:34:28
问题 scrollTop doesn't work every other click (every second click). I use will_paginate at the bottom of the page. When I click on a link, the page is refreshed and the display position is at the bottom of the page. Then I click on a link to another page, the page is refreshed and the display position is at the top of the page as I expect. For example, When I click the link to page 2, the page 2 is displayed but the display position remains at the bottom. When I click the link to page 5, the page

Joining files in Coffescript

可紊 提交于 2019-12-11 22:14:11
问题 I am currently looking to use RequireJS to ensure modularity in the front end side of my project written in Coffeescript. Is there a way to use "import" directives in coffeescript so that you could recursive compile a large number of ".coffee" files into a single ".js" file - and potentially minify it too. I know there is a "join" argument you can pass to the coffeescript compiler, but it would be really useful to just reference files from one to another. Secondly, it should be able to do

Getting around asynchronous requests

£可爱£侵袭症+ 提交于 2019-12-11 21:57:02
问题 So I have a function like this - IPGeocoding = (data) -> coords = [] _.each(data, (datum) -> $.ajax( url: "http://freegeoip.net/json/#{datum}" type: 'GET' async: false success: (result) -> lat = result.latitude lon = result.longitude pair = [lat, lon] coords.push(pair) console.log coords ) return coords ) I want coords to only be returned when all of the requests have returned. How do I do that? 回答1: Underscore comes bundled with a _.after method. _.after takes two arguments. The second is