سؤال

I'm creating web service field in my xform file. My destiny is to have two fields, for example: name and welcome message. The scenario is: user write his name in name input field, and when he do this, in welcome message input field appear text from web service. I reach very similar effect, but using button (trigger): user write his name, click on button, and then appear message. I want to do this without button, using some on-change event, but I don't know how.

My code:

<fr:grid>                                                                                                
   <xh:tr>                            
      <xh:td> 
         <xf:input bind="name-bind" id="name">
            <xf:label>Your name</xf:label>
         </xf:input> 
      </xh:td>                            
      <xh:td>        
         <xf:input bind="welcome-bind" id="welcome">
            <xf:label>Welcome text</xf:label>
         </xf:input>
         <xf:trigger>                                                                                                            
            <xf:label>Generate welcome from WS</xf:label>                             
            <xf:send ev:event="DOMActivate" submission="my-submission"/>                                                                                                         
         </xf:trigger>                              
      </xh:td>                            
   </xh:tr>                     
</fr:grid>

If somebody know how change my code, to reach described effect, give me some advice please.

regards

هل كانت مفيدة؟

المحلول

If you'd like the submission to run when users change the value in the name field and leave the field to go to another field (e.g. tabbing out of the field), then you can write:

<xf:input bind="name-bind" id="name">
    <xf:label>Your name</xf:label>
    <xf:send ev:event="xforms-value-changed" submission="my-submission"/> 
</xf:input> 

You can also add DOMActivate in addition to xforms-value-changed (the value of ev:event can be a space separated list of events), if you want the submission to also run if users press enter after typing a value in the field.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top