When using dynamic ajax replace, e.g. replace("MYPH");, attribute values of called templates within the replaced placeholder hold the old values from before the action that replaces the placeholder.

In the following example, the class of the <h1> element (decorate template) renders the old value "old" after updating the string with "new" in the inputTemplate.

 page root(){    
    var someString := "old";
    
    placeholder "MYPH" { showString( someString ) }
    inputTemplate( someString )
  }
  
  template inputTemplate( stringRef : Ref<String>){
    var i := ""
    form{  input(i)[onkeyup=update(), class="input1"] }    
    action update(){ stringRef := i; replace("MYPH"); }
  }
  
  template showString( str : String ){
    decorate[class=if(str == "new") "new" else "old"] { output(str) }
    "plain: " output(str)
  }
  
  template decorate() {
    <h1 all attributes> "decorated: " elements </h1>    
  }
Submitted by Elmer van Chastelet on 15 December 2021 at 10:12

On 16 December 2021 at 21:01 Elmer van Chastelet closed this issue.

Log in to post comments