Sunday, March 15, 2015

How to Access Coach View element in Custom HTML - Part 2


This blog is continuation of my other blog - How to Access Coach View element in Custom HTML .
In this blog, let us see how to access various Stock coach view (check box, integer, combo box, radio button, etc) element's values.

Check Box Coach View

Consider a Check box coach view with control-id "checkbox_1",below is the code that can be used to access the value of the coach view. Below code attaches onClick event to the checkbox and on click of the check box, it gives a popup with value of check box as shown in the figure below.

<script>
require(["dojo/ready", "dojo/query","dojo/on"],function(ready, query,on){
  ready(function(){
     // Check Box element
  var check=query("div[data-viewid='checkbox_1'] input[role='checkbox']")[0];
           on(check, "click", function(){
                      alert(check.checked)
                    
          });
    });
});
</script>



popup on click of the Check Box

Select Coach View

Consider a Select coach view with control-id "Select1",below is the code that can be used to access the value of the select coach view. Below code attaches onClick event to the button and on click of the button, it gives a popup with value selected as shown in the figure below.

<script>
require(["dojo/ready", "dojo/query","dojo/on"],function(ready, query,on){
  ready(function(){
     // select coach view element
  var comboElements=query("div[data-viewid='Select1'] .dijitInputField input");
 
  var buttonElement=  query("div[data-viewid='Button1']")[0];
           on(buttonElement, "click", function(){
               
               alert(comboElements[0].value)
                   
          });
    });
});
</script>


Popup with value selected in combo box


More elements to come !!! Wait and watch -:)
you may also like :  How to Access Coach view element in custom Html

Thanks for stopping by. If you like this post leave a comment, share it and do a g +1.



3 comments:

  1. Thanks for such easy demonstration.. I need some help from you.. I have a dropdown and textbox and I want to set some default in textbox whenever selected value in dropdown is changed. Basically I want to execute some script on onChange event of dropdown.. Can you help me on that?

    ReplyDelete
  2. Hi , I have followed all the steps in human service coach alone but it doesn't work.

    ReplyDelete
  3. Hi Vasudha, I have recently noticed that this code is working in IE with out any issues, but when tried in Chrome it doesn't work. Which browser have you tried in?

    ReplyDelete