fixed bug for autocomplete in member personal journals
This commit is contained in:
parent
075acef5d8
commit
5ac4d065e2
|
@ -1,34 +1,33 @@
|
|||
<script type="text/javascript">
|
||||
var map = {},
|
||||
members = [],
|
||||
data = <%= raw @members_data %>;
|
||||
$.each(data, function (i, member) {
|
||||
map[member.memberName] = member;
|
||||
members.push(member.memberName);
|
||||
});
|
||||
$(document).ready(function(){
|
||||
$('#search').typeahead({
|
||||
$('#member_autocomplete').typeahead({
|
||||
source: function (query, process) {
|
||||
members = [];
|
||||
map = {};
|
||||
|
||||
var data = <%=raw @members_data%>;
|
||||
$.each(data, function (i, member) {
|
||||
map[member.memberName] = member;
|
||||
members.push(member.memberName);
|
||||
});
|
||||
process(members);
|
||||
},
|
||||
updater: function (item) {
|
||||
selectedMember = map[item].memberId;
|
||||
$('#member_value').val(selectedMember);
|
||||
return item;
|
||||
},
|
||||
matcher: function (item) {
|
||||
if (item.toLowerCase().indexOf(this.query.trim().toLowerCase()) != -1) {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
sorter: function (items) {
|
||||
return items.sort();
|
||||
},
|
||||
highlighter: function (item) {
|
||||
var regex = new RegExp( '(' + this.query + ')', 'gi' );
|
||||
return item.replace( regex, "<strong>$1</strong>" );
|
||||
},
|
||||
return members;
|
||||
},
|
||||
updater: function (item) {
|
||||
selectedMember = map[item].memberId;
|
||||
$('#member_value').val(selectedMember);
|
||||
return item;
|
||||
},
|
||||
matcher: function (item) {
|
||||
if (item.toLowerCase().indexOf(this.query.trim().toLowerCase()) != -1) {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
sorter: function (items) {
|
||||
return items.sort();
|
||||
},
|
||||
highlighter: function (item) {
|
||||
var regex = new RegExp( '(' + this.query + ')', 'gi' );
|
||||
return item.replace( regex, "<strong>$1</strong>" );
|
||||
},
|
||||
});
|
||||
});
|
||||
</script>
|
|
@ -88,7 +88,7 @@
|
|||
<div class="control-group input-title">
|
||||
<label class="control-label muted"><%= t("personal_journal.author") %></label>
|
||||
<div class="controls">
|
||||
<%= f.text_field :member_profile_id, id: "search", autocomplete: "off", data: { provide: "typeahead"}, class: "input-block-level", value: (@journal_paper.member_profile.name rescue nil), placeholder: t("personal_journal.author")%>
|
||||
<%= f.text_field :member_profile_id, id: "member_autocomplete", autocomplete: "off", data: { provide: "typeahead"}, class: "input-block-level", value: (@journal_paper.member_profile.name rescue nil), placeholder: t("personal_journal.author")%>
|
||||
|
||||
<%= f.hidden_field :member_profile_id, value: (@journal_paper.member_profile_id ? @journal_paper.member_profile_id : ""), id: "member_value" %>
|
||||
</div>
|
||||
|
@ -311,8 +311,6 @@
|
|||
<%= f.submit t('submit'), class: 'btn btn-primary' %>
|
||||
<%= link_to t('cancel'), get_go_back, :class=>"btn" %>
|
||||
</div>
|
||||
|
||||
|
||||
<%= render 'author_autocomplete'%>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
|
|
Loading…
Reference in New Issue