37
37
return value ;
38
38
} ;
39
39
40
- blocks . version = '0.3.2 ' ;
40
+ blocks . version = '0.3.3 ' ;
41
41
blocks . core = core ;
42
42
43
43
/**
@@ -8658,6 +8658,8 @@ return result;
8658
8658
blocks . each ( createVirtual ( this . childNodes [ 0 ] ) , function ( element ) {
8659
8659
if ( VirtualElement . Is ( element ) ) {
8660
8660
element . sync ( domQuery ) ;
8661
+ } else if ( element && element . isExpression && element . element ) {
8662
+ element . element . nodeValue = Expression . GetValue ( domQuery . _context , null , element ) ;
8661
8663
}
8662
8664
} ) ;
8663
8665
domQuery . createElementObservableDependencies ( this . childNodes ) ;
@@ -9738,7 +9740,7 @@ return result;
9738
9740
return this ;
9739
9741
} ,
9740
9742
9741
- sync : function ( ) {
9743
+ sync : function ( callback ) {
9742
9744
var _this = this ;
9743
9745
var changes = this . _changes ;
9744
9746
var changesLeft = changes . length ;
@@ -9755,11 +9757,15 @@ return result;
9755
9757
} , function ( ) {
9756
9758
changesLeft -- ;
9757
9759
if ( ! changesLeft ) {
9760
+ if ( blocks . isFunction ( callback ) ) {
9761
+ callback ( ) ;
9762
+ }
9758
9763
_this . _trigger ( 'sync' ) ;
9759
9764
}
9760
9765
} ) ;
9761
9766
} ) ;
9762
9767
} ) ;
9768
+
9763
9769
return this . clearChanges ( ) ;
9764
9770
} ,
9765
9771
@@ -10209,13 +10215,15 @@ return result;
10209
10215
* Synchronizes the changes with the server by sending requests to the provided URL's
10210
10216
*
10211
10217
* @memberof Model
10218
+ * @param {Function } [callback] - Optional callback which will be executed
10219
+ * when all sync operations have been successfully completed
10212
10220
* @returns {Model } - Returns the Model itself - return this;
10213
10221
*/
10214
- sync : function ( ) {
10222
+ sync : function ( callback ) {
10215
10223
if ( this . isNew ( ) ) {
10216
10224
this . _dataSource . data . add ( this . dataItem ( ) ) ;
10217
10225
}
10218
- this . _dataSource . sync ( ) ;
10226
+ this . _dataSource . sync ( callback ) ;
10219
10227
return this ;
10220
10228
} ,
10221
10229
@@ -10723,6 +10731,8 @@ return result;
10723
10731
* with a database.
10724
10732
*
10725
10733
* @memberof Collection
10734
+ * @param {Function } [callback] - Optional callback which will be executed
10735
+ * when all sync operations have been successfully completed
10726
10736
* @returns {Collection } - Chainable. Returns the Collection itself - return this;
10727
10737
*
10728
10738
* @example {javascript}
@@ -10748,8 +10758,8 @@ return result;
10748
10758
* }
10749
10759
* });
10750
10760
*/
10751
- sync : function ( ) {
10752
- this . _dataSource . sync ( ) ;
10761
+ sync : function ( callback ) {
10762
+ this . _dataSource . sync ( callback ) ;
10753
10763
return this ;
10754
10764
} ,
10755
10765
@@ -10846,24 +10856,18 @@ return result;
10846
10856
function View ( application , parentView , prototype ) {
10847
10857
var _this = this ;
10848
10858
var options = this . options ;
10849
- var views = this . _views = [ ] ;
10850
- var hasRoute = blocks . has ( options , 'route' ) ;
10851
10859
10852
10860
clonePrototype ( prototype , this ) ;
10853
10861
10862
+ this . _views = [ ] ;
10854
10863
this . _application = application ;
10855
10864
this . _parentView = parentView || null ;
10856
10865
this . _initCalled = false ;
10857
10866
this . _html = undefined ;
10858
10867
10859
10868
this . loading = blocks . observable ( false ) ;
10860
- this . isActive = blocks . observable ( ! hasRoute ) ;
10869
+ this . isActive = blocks . observable ( ! blocks . has ( options , 'route' ) ) ;
10861
10870
this . isActive . on ( 'changing' , function ( oldValue , newValue ) {
10862
- blocks . each ( views , function ( view ) {
10863
- if ( ! hasRoute ) {
10864
- view . isActive ( newValue ) ;
10865
- }
10866
- } ) ;
10867
10871
_this . _tryInitialize ( newValue ) ;
10868
10872
} ) ;
10869
10873
@@ -10907,10 +10911,10 @@ return result;
10907
10911
/**
10908
10912
* Override the ready method to perform actions when the DOM is ready and
10909
10913
* all data-query have been executed.
10910
- *
10914
+ *
10911
10915
* @memberof View
10912
10916
* @type {Function }
10913
- *
10917
+ *
10914
10918
* @example {javascript}
10915
10919
* var App = blocks.Application();
10916
10920
*
@@ -10943,20 +10947,20 @@ return result;
10943
10947
* });
10944
10948
*/
10945
10949
routed : blocks . noop ,
10946
-
10950
+
10947
10951
/**
10948
10952
* Observable which value is true when the View html
10949
10953
* is being loaded using ajax request. It could be used
10950
10954
* to show a loading indicator.
10951
- *
10955
+ *
10952
10956
* @memberof View
10953
10957
*/
10954
10958
loading : blocks . observable ( false ) ,
10955
10959
10956
10960
/**
10957
10961
* Gets the parent view.
10958
10962
* Returns null if the view is not a child of another view.
10959
- *
10963
+ *
10960
10964
* @memberof View
10961
10965
*/
10962
10966
parentView : function ( ) {
@@ -11013,7 +11017,7 @@ return result;
11013
11017
this . _tryInitialize ( true ) ;
11014
11018
this . routed ( params , metadata ) ;
11015
11019
blocks . each ( this . _views , function ( view ) {
11016
- if ( view . isActive ( ) ) {
11020
+ if ( ! view . options . route ) {
11017
11021
view . _routed ( params , metadata ) ;
11018
11022
}
11019
11023
} ) ;
0 commit comments