This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var View = Backbone.View.extend({ | |
render: function() { | |
this.$el.html("View exemplo"); | |
return this; | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// View = gist 6201b9d1d2d74c673dd0 | |
var view = new View(); | |
view.render(); // Adicionando o conteúdo na view | |
$("div").html(view.el); // Adiciona a view no DOM |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var View = Backbone.View.extend({ | |
events: { | |
"click .item": "clicked" | |
}, | |
clicked: function() { | |
console.log("Item clicado"); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var View = Backbone.View.extend({ | |
template: _.template("<h1> Título da View </h1>"), | |
render: function() { | |
this.$el.html(this.template()); | |
return this; | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var View = Backbone.View.extend({ | |
template: _.template("<h1> <%= title %> </h1>"), // O template espera title como variavel | |
render: function() { | |
this.$el.html(this.template(this.model.attributes)); // Passando o title para o template | |
return this; | |
} | |
}); | |
var view = new View({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var View = Backbone.View.extend({ | |
tagName: "ul", // Por padrão é gerado uma div, mas podemos colocar outra tag (por exemplo uma <ul>) | |
className: "minha-ul", // Podemos adicioanar uma class ao elemento da view (<ul class='minha-ul'></ul>) | |
id: "minha-ul", // Mesma coisa do className só que para adicionar um id (<ul id='minha-ul'></ul>) | |
el: "#principal", // Se o elemento já esta renderizado na página, podemos passar o el, assim ele não cria um elemento novo | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
runApp(new MyApp()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter_app/main.dart'; | |
import 'package:flutter_test/flutter_test.dart'; | |
import 'package:mockito/mockito.dart'; | |
class FakeFunctions { | |
void runApp(dynamic widget) {} | |
} | |
class FunctionsMock extends Mock implements FakeFunctions {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() { | |
App().bootstrap(runApp); | |
} | |
class App { | |
Future<void> bootstrap(Function runner) async { | |
// ...before | |
runner(MyApp()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() => runApp(new MaterialApp(home: new MyApp(), debugShowCheckedModeBanner: false,),); | |
class MyApp extends StatefulWidget { | |
@override | |
_MyAppState createState() => new _MyAppState(); | |
} | |
class _MyAppState extends State<MyApp> { |
OlderNewer