5 /phenome/associate_locus.mas - a component for printing a generic 'associate_locus' javasript form
9 a component for printing an autocomplete form for searching loci and associating with your object
22 the name of the object you are associating the locus with (e.g. 'stock')
24 =item locus_autocomplete_uri
26 the uri for the code which retrieves the locus info
30 the uri for storing the link in the database
34 optional. default 0. If the user is logged in, you might want to set this to 1 and display the form. Either way, associating loci permissions should also be enforced in your 'add' function
38 a unique name for your div_id for updating content in your page without reloading.
44 Naama Menda <nm249@cornell.edu>
55 $locus_autocomplete_uri => '/ajax/locus/autocomplete'
62 <& /util/import_javascript.mas, classes=>[qw[ jquery jqueryui popup]] &>
66 <div id = "<% $allele_div %>" > Loading..</div>
69 <div id="associate_locus_form" class="container-fluid">
70 <div id="locus_search" >
71 <form name="loci_form" class="form-horizontal">
73 <div class="form-group">
74 <label for="loci" class="col-sm-6 control-label">Associate another Locus:</label>
75 <div class="input-group col-sm-6">
76 <input class="form-control" placeholder="Allele_name (Allele_symbol) Allele: AA" type="text" id="loci" name="loci">
77 <span class="input-group-btn">
78 <button class="btn btn-primary" type="button" id="associate_allele_addon" name="associate_locus" onclick="javascript:submit_locus_form()">Associate locus</button>
82 <input type="hidden" id="object_id" name="object_id" value="<% $object_id %>" />
89 </div><!-- closes well -->
92 <script language="javascript">
93 display_alleles("<% $allele_div %>");
95 jQuery(document).ready(function() {
96 jQuery("#loci").autocomplete({
97 source: '<% $locus_autocomplete_uri %>'
101 function submit_locus_form() {
102 //make an AJAX request with the form params
103 var loci = jQuery("#loci").val();
104 jQuery.ajax({ url: "<% $locus_add_uri %>" , method:"GET", data: 'object_id='+<% $object_id %>+'&loci='+loci ,
105 success: function(response) {
106 var error = response.error;
107 if (error) { alert(error) ; }
108 display_alleles( "<% $allele_div %>" );
113 function display_alleles(allele_div) {
114 jQuery.ajax( { url: "/<% $object_name %>/<% $object_id %>/alleles" , dataType: "json",
115 success: function(response) {
117 jQuery("#"+allele_div).html(response.html);