Skip to content

Instantly share code, notes, and snippets.

What is the proper way to load requirejs modules for models/views/collections in a backbone project?

I am using Yeoman to create a scaffolding for the app and am only starting to use require js.

My main.js file:

require.config({
    paths: {
        jquery: '../components/jquery/jquery',
fade: (opacity, callback) -> | 10 if (url === this.get('currentView.src')){
11 currentOpacity = @$().css('opacity') | 11 this.get('controller.videoPromise').resolve();
12 return callback() if currentOpacity == opacity | 12 return;
13 | 13 }
14 @$().css('opacity', opacity) | 14
{{view "Application.CrossfadeVideoContainerView" url=videoUrl class="crossfade-container"}}
Application.LoadingTransitionMixin = Ember.Mixin.create
afterModel: (model, transition) ->
previousRoute = @get('router').previousRoute
if previousRoute
@get('router').previousRoute.cleanUp()
cleanUp: ->
deferredPromise = new Ember.Deferred()
@controller.set('cleanUpPromise', deferredPromise)
@denisnazarov
denisnazarov / interacting_jquery.js
Created November 20, 2013 14:41
Interacting with jQuery events in Ember.js Views
// jQuery event handler in the View
didInsertElement: function () {
var self = this;
this._boundApplyResize = function(){
self.applyResize();
}
$(window).on('resize', this._boundApplyResize);
},
li > ul{
display: none;
}
@denisnazarov
denisnazarov / full-screen-video.css
Created December 24, 2013 21:24
Full screen (background) video with just CSS: http://jsbin.com/EzakOYIb/1
.full-screen-video-container{
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
overflow: hidden;
}
.full-screen-video-container video{
position: absolute;
@denisnazarov
denisnazarov / app.css
Created February 20, 2014 03:51
Ember Youtube Loop Component http://emberjs.jsbin.com/tadaseku/3/
/* Put your CSS here */
html, body {
margin: 10px;
}
form{
width: 560px;
margin-bottom: 10px;
}
.ui-slider-horizontal .ui-slider-handle {
width: 2px;
@denisnazarov
denisnazarov / app.css
Created February 20, 2014 03:53
Ember Resizable Image Component http://jsbin.com/ucanam/3882/edit
.sized-container{
position: relative;
}
.element-resize{
position: absolute;
bottom: 0px;
right: 0px;
width: 20px;
height: 20px;
background-color: black;
@denisnazarov
denisnazarov / video_convert.sh
Last active October 31, 2016 13:40
FFMPEG batch convert to h264 mp4 and webm
#! /bin/bash
# Based on Batch Convert Script originally by Beterhans
# Put all video files need to be converted in a folder!
# the name of files must not have " " Space!
# Rename the File if contain space
# Target dir
indir=$1