@@ -43,15 +43,19 @@ define([
4343 }
4444 $el . data ( "pat-inject" , cfgs ) ;
4545
46- // In case next-href is specified the anchor's href will
47- // be set to it after the injection is triggered. In case
48- // the next href already exists, we do not activate the
49- // injection but instead just change the anchors href.
50- var $nexthref = $ ( cfgs [ 0 ] . nextHref ) ;
51- if ( $el . is ( "a" ) && $nexthref . length > 0 ) {
52- log . debug ( "Skipping as next href already exists" , $nexthref ) ;
53- // XXX: reconsider how the injection enters exhausted state
54- return $el . attr ( { href : ( window . location . href . split ( "#" ) [ 0 ] || "" ) + cfgs [ 0 ] . nextHref } ) ;
46+ if ( cfgs [ 0 ] . nextHref && cfgs [ 0 ] . nextHref . indexOf ( '#' ) === 0 ) {
47+ // In case the next href is an anchor, and it already
48+ // exists in the page, we do not activate the injection
49+ // but instead just change the anchors href.
50+
51+ // XXX: This is used in only one project for linked
52+ // fullcalendars, it's sanity is wonky and we should
53+ // probably solve it differently.
54+ if ( $el . is ( "a" ) && $ ( cfgs [ 0 ] . nextHref ) . length > 0 ) {
55+ log . debug ( "Skipping as next href is anchor, which already exists" , cfgs [ 0 ] . nextHref ) ;
56+ // XXX: reconsider how the injection enters exhausted state
57+ return $el . attr ( { href : ( window . location . href . split ( "#" ) [ 0 ] || "" ) + cfgs [ 0 ] . nextHref } ) ;
58+ }
5559 }
5660
5761 switch ( cfgs [ 0 ] . trigger ) {
@@ -118,7 +122,7 @@ define([
118122 cfgs = $sub . data ( "pat-inject" ) ;
119123
120124 // store the params of the subform in the config, to be used by history
121- $ ( cfgs ) . each ( function ( i , v ) { v . params = $ . param ( $sub . serializeArray ( ) ) } ) ;
125+ $ ( cfgs ) . each ( function ( i , v ) { v . params = $ . param ( $sub . serializeArray ( ) ) ; } ) ;
122126
123127 try {
124128 $el . trigger ( "patterns-inject-triggered" ) ;
@@ -407,9 +411,10 @@ define([
407411 inject . _performInjection . apply ( this , [ $el , sources$ [ idx ] , cfg , ev . target ] ) ;
408412 } ) ;
409413 } ) ;
410- if ( cfgs [ 0 ] . nextHref ) {
411- $el . attr ( { href : ( window . location . href . split ( "#" ) [ 0 ] || "" ) +
412- cfgs [ 0 ] . nextHref } ) ;
414+ if ( cfgs [ 0 ] . nextHref && $el . is ( "a" ) ) {
415+ // In case next-href is specified the anchor's href will
416+ // be set to it after the injection is triggered.
417+ $el . attr ( { href : cfgs [ 0 ] . nextHref } ) ;
413418 inject . destroy ( $el ) ;
414419 }
415420 $el . off ( "pat-ajax-success.pat-inject" ) ;
0 commit comments