1
- /*! JsObservable v0.9.82 (Beta): http://jsviews.com/#jsobservable */
1
+ /*! JsObservable v0.9.83 (Beta): http://jsviews.com/#jsobservable */
2
2
/*
3
3
* Subcomponent of JsViews
4
4
* Data change events for data-linking
@@ -44,7 +44,7 @@ if (!$ || !$.fn) {
44
44
throw "JsObservable requires jQuery" ; // We require jQuery
45
45
}
46
46
47
- var versionNumber = "v0.9.82 " ,
47
+ var versionNumber = "v0.9.83 " ,
48
48
$observe , $observable ,
49
49
50
50
$views = $ . views =
@@ -461,8 +461,8 @@ if (!$.observe) {
461
461
}
462
462
}
463
463
464
- var i , p , skip , parts , prop , path , dep , unobserve , callback , cbId , inId , el , data , events , contextCb , items , cbBindings ,
465
- depth , innerCb , parentObs , allPath , filter , initNsArr , initNsArrLen ,
464
+ var i , p , skip , parts , prop , path , dep , unobserve , callback , cbId , inId , el , data , events , contextCb , innerContextCb ,
465
+ items , cbBindings , depth , innerCb , parentObs , allPath , filter , initNsArr , initNsArrLen ,
466
466
ns = observeStr ,
467
467
paths = this != 1 // Using != for IE<10 bug- see jsviews/issues/237
468
468
? concat . apply ( [ ] , arguments ) // Flatten the arguments - this is a 'recursive call' with params using the 'wrapped array'
@@ -491,7 +491,7 @@ if (!$.observe) {
491
491
}
492
492
callback = lastArg ;
493
493
if ( l && $isFunction ( paths [ l - 1 ] ) ) {
494
- contextCb = callback ;
494
+ innerContextCb = contextCb = callback ;
495
495
callback = paths . pop ( ) ;
496
496
l -- ;
497
497
}
@@ -544,6 +544,11 @@ if (!$.observe) {
544
544
if ( path === "" ) {
545
545
continue ;
546
546
}
547
+ if ( path && path . _cp ) { // Contextual parameter
548
+ contextCb = $sub . _gccb ( path [ 0 ] ) ; // getContextCb: Get context callback for the contextual view (where contextual param evaluated/assigned)
549
+ origRoot = root = path [ 0 ] . data ; // Contextual data
550
+ path = path [ 1 ] ;
551
+ }
547
552
object = root ;
548
553
if ( "" + path === path ) {
549
554
// Consider support for computed paths: jsviews/issues/292
@@ -562,7 +567,11 @@ if (!$.observe) {
562
567
depth = path . split ( "." ) . length - depth ;
563
568
// if more than one ^ in the path, the first one determines depth
564
569
}
565
- if ( contextCb && ( items = contextCb ( path , root , depth ) ) ) {
570
+ if ( contextCb ) {
571
+ items = contextCb ( path , root , depth ) ;
572
+ contextCb = innerContextCb ;
573
+ }
574
+ if ( items ) {
566
575
// If the array of objects and paths returned by contextCb is non empty, insert them
567
576
// into the sequence, replacing the current item (path). Otherwise simply remove current item (path)
568
577
l += items . length - 1 ;
@@ -1107,6 +1116,7 @@ if (!$.observe) {
1107
1116
} ;
1108
1117
1109
1118
$sub . advSet = function ( ) { // refresh advanced settings
1119
+ $sub . _gccb = this . _gccb ; // getContextCallback method
1110
1120
global . _jsv = $subSettings . advanced . _jsv
1111
1121
? { // create global _jsv, for accessing views, etc
1112
1122
cbBindings : cbBindingsStore
0 commit comments