You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: index.md
+40-43Lines changed: 40 additions & 43 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -115,7 +115,7 @@ var hobbies = new can.Observe.List( ['programming',
115
115
'party rocking'] )
116
116
{% endhighlight %}
117
117
118
-
__can.Observe__ is used by both __can.Model__ and __can.route__. However, observe
118
+
__can.Observe__ is used by both [can.Model](#can_model) and [can.route](#can_route). However, observe
119
119
is useful on its own to maintain client-side state (such as pagination data).
120
120
121
121
### attr `observe.attr( [name,] [value] )`
@@ -457,7 +457,7 @@ Todo.bind( 'created', function( ev, todo ){
457
457
458
458
[can.Model.List](http://donejs.com/docs.html#!can.Model.List) is a
459
459
[can.Observe.List](#can_observe-can_observe_list) that automatically removes items when they are
460
-
destroyed. __Model.Lists__ are return by [findAll](#can_model-findall).
460
+
destroyed. __Model.Lists__ are returned by [findAll](#can_model-findall).
461
461
462
462
{% highlight javascript %}
463
463
Todo.findAll( {}, function( todos ) {
@@ -973,10 +973,9 @@ The selector can also be templated.
973
973
974
974
Control can also bind to objects other than `this.element` with
975
975
templated event handlers. This is _critical
976
-
for avoiding memory leaks that are common among MVC applications.
976
+
for avoiding memory leaks that are common among MVC applications_.
977
977
978
-
If the value inside `{NAME}` is an object, the event will be bound to that object
979
-
that object rather than the control. For example, the following tooltip listens to
978
+
If the value inside `{NAME}` is an object, the event will be bound to that object rather than the control. For example, the following tooltip listens to
980
979
clicks on the window:
981
980
982
981
{% highlight javascript %}
@@ -1478,38 +1477,36 @@ jQuery events, so for those cases, a workaround should be applied:
1478
1477
<scriptsrc="jquery.ui.datepicker.js"></script>
1479
1478
<scriptsrc="can.jquery.js"></script>
1480
1479
<script>
1481
-
YUI().use('can', 'calendar', function(Y) {
1482
-
// create models
1483
-
Todo =can.Model({ ... });
1484
-
Todo.List=can.Model.List({ ... });
1485
-
1486
-
// create control
1487
-
Todos =can.Control({
1488
-
// listen to the calendar widget's datepickerselect event
var selectedDate =this.options.calendar.datepicker('getDate');
1490
+
...
1491
+
}
1492
+
});
1493
+
1494
+
// Initialize the app
1495
+
Todo.findAll({}, function(todos) {
1496
+
newTodos('#todoapp', {
1497
+
todos: todos,
1498
+
calendar:$('#calendar').hide().datepicker({
1499
+
// Adding a workaround for date selection since the
1500
+
// jQuery UI datepicker widget doesn't fire the
1501
+
// "datepickerselect" event
1502
+
onSelect:function(dateText, datepicker) {
1503
+
$(this).trigger({
1504
+
type:'datepickerselect',
1505
+
text: dateText,
1506
+
target: datepicker
1507
+
});
1508
+
}
1509
+
})
1513
1510
});
1514
1511
});
1515
1512
</script>
@@ -1520,7 +1517,7 @@ jQuery events, so for those cases, a workaround should be applied:
1520
1517
CanJS supports Dojo 1.7+ using its new AMD loader in asynchronous or synchronous mode.
1521
1518
CanJS depends on the following Dojo modules: __dojo__, __dojo/query__, __dojo/NodeList-dom__ and __dojo/NodeList-traverse__. It also uses the __plugd/trigger__ plugin for internal object and node event triggering.
1522
1519
1523
-
Include Dojo in your page and add the `'can/dojo'` module as a dependency in your require statement.
1520
+
Include a copy of Dojo and add the `'can/dojo'` module as a dependency in your require statement to get started.
//Using require to load can/dojo from the local directory
1565
+
//Using require to load can/dojo from a local directory
1569
1566
require({
1570
1567
packages: [{
1571
1568
name:"can/dojo",
@@ -1581,14 +1578,14 @@ require({
1581
1578
</script>
1582
1579
{% endhighlight %}
1583
1580
1584
-
CanJS can bind to any Dijit, Dojox or custom widget events using [templated event binding](#can_control-templated_event_handlers_pt_2). Below is an example of binding to the onchnage event of the dijit.CalendarLite widget:
1581
+
CanJS can bind to any Dijit, Dojox or custom widget events using [templated event binding](#can_control-templated_event_handlers_pt_2). Below is an example of binding to the __onChange__ event of the dijit.CalendarLite widget:
1585
1582
1586
1583
{% highlight javascript %}
1587
1584
require(['can/dojo',
1588
1585
'dijit/CalendarLite'],
1589
1586
function(can, CalendarLite){
1590
1587
//Define a Control
1591
-
var Todos = can.Control({
1588
+
Todo = can.Control({
1592
1589
//events are lowercase and don't use on (onChange -> change)
@@ -2089,7 +2086,7 @@ listen and interact with the `video` element.
2089
2086
2090
2087
### Srchr
2091
2088
2092
-
Srchr searches several data sources for content and displays it to the user. It is built using the jQuery version of CanJS and is a greate example of how to create dumb, isolated widgets that are loosely coupled to the rest of the application.
2089
+
Srchr searches several data sources for content and displays it to the user. It is built using the jQuery version of CanJS and is a great example of how to create dumb, isolated widgets that are loosely coupled to the rest of the application.
0 commit comments