Commit f7c765f2d06af4bcd82c628aad3fdc53f64bed9d
1 parent
96d582a3
Exists in
colab
and in
4 other branches
Fix branches not being fetched after page load on repository form
Signed-off-by: Daniel Miranda <danielkza2@gmail.com>
Showing
1 changed file
with
10 additions
and
3 deletions
Show diff stats
app/views/repositories/_form.html.erb
| ... | ... | @@ -43,7 +43,7 @@ |
| 43 | 43 | <div class="form-row"> |
| 44 | 44 | <div class="field-container"> |
| 45 | 45 | <%= f.label :scm_type, class: 'control-label' %> |
| 46 | - <%= f.select( :scm_type, @repository_types, {}, class: 'tooltip-control', onchange: "show_branches(this);" ) %> | |
| 46 | + <%= f.select( :scm_type, @repository_types, {}, class: 'tooltip-control', onchange: "show_branches();" ) %> | |
| 47 | 47 | </div> |
| 48 | 48 | <div class="help-container"> |
| 49 | 49 | <p> |
| ... | ... | @@ -111,7 +111,8 @@ |
| 111 | 111 | |
| 112 | 112 | |
| 113 | 113 | <script> |
| 114 | - function show_branches (scm_type_field) { | |
| 114 | + function show_branches () { | |
| 115 | + var scm_type_field = document.getElementById("repository_scm_type"); | |
| 115 | 116 | var index = scm_type_field.selectedIndex; |
| 116 | 117 | var option = scm_type_field.options[index]; |
| 117 | 118 | |
| ... | ... | @@ -125,6 +126,12 @@ |
| 125 | 126 | </script> |
| 126 | 127 | |
| 127 | 128 | <script> |
| 129 | + $(document).on('page:load ready', function() { | |
| 130 | + show_branches(); | |
| 131 | + }); | |
| 132 | +</script> | |
| 133 | + | |
| 134 | +<script> | |
| 128 | 135 | var branches = {}; |
| 129 | 136 | var request = null; |
| 130 | 137 | function fetch_branches (address_field) { |
| ... | ... | @@ -135,7 +142,7 @@ |
| 135 | 142 | el.empty(); // remove old options |
| 136 | 143 | |
| 137 | 144 | console.log(address); |
| 138 | - if(branches[address] != undefined) { | |
| 145 | + if(branches[address] != null) { | |
| 139 | 146 | fill_options(branches[address], el); |
| 140 | 147 | return; |
| 141 | 148 | } | ... | ... |