Commit ecfffead authored by Ryan Herbert's avatar Ryan Herbert
Browse files

tokeniser.js file/form.html fix token deletion

token deletion would remove the span and no longer display the token,
but the hidden input which contains the values to be sent to the
controller was not updated correctly and would require a new set to be
added before containing the new value.
parent c4a6d643
......@@ -71,3 +71,18 @@ Tokeniser.prototype.createToken = function(set_id) {
return token;
}
Tokeniser.prototype.removeToken = function(token) {
this.target.removeChild(token);
this.form_input.value = this.readTokens();
return token;
}
Tokeniser.prototype.createCloseButton = function() {
var self = this;
var close = Object.getPrototypeOf(Tokeniser.prototype).createCloseButton.call(this);
close.onclick = function() {
self.removeToken(this.parentNode);
}
return close;
}
......@@ -48,7 +48,7 @@
<div id="set_div_{{=0}}" class="token_container">
{{ for set in sets: }}
<span class="set_token {{=set['type']}}_token" data-set-id="{{=set['id']}}">
<i class="icon-cancel" onclick="this.parentNode.parentNode.removeChild(this.parentNode);"></i>
<i class="icon-cancel" onclick="new Tokeniser(document.getElementById('set_div_{{=0}}'), document.getElementById('file_set_list_{{=0}}')).removeToken(this.parentNode);"></i>
{{=set['id'][3:]}}
</span>
{{pass}}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment