forked from saurabh/personal-journal
fixed bug for autocomplete in member personal journals
This commit is contained in:
parent
075acef5d8
commit
5ac4d065e2
|
@ -1,16 +1,15 @@
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).ready(function(){
|
var map = {},
|
||||||
$('#search').typeahead({
|
members = [],
|
||||||
source: function (query, process) {
|
data = <%= raw @members_data %>;
|
||||||
members = [];
|
|
||||||
map = {};
|
|
||||||
|
|
||||||
var data = <%=raw @members_data%>;
|
|
||||||
$.each(data, function (i, member) {
|
$.each(data, function (i, member) {
|
||||||
map[member.memberName] = member;
|
map[member.memberName] = member;
|
||||||
members.push(member.memberName);
|
members.push(member.memberName);
|
||||||
});
|
});
|
||||||
process(members);
|
$(document).ready(function(){
|
||||||
|
$('#member_autocomplete').typeahead({
|
||||||
|
source: function (query, process) {
|
||||||
|
return members;
|
||||||
},
|
},
|
||||||
updater: function (item) {
|
updater: function (item) {
|
||||||
selectedMember = map[item].memberId;
|
selectedMember = map[item].memberId;
|
||||||
|
|
|
@ -88,7 +88,7 @@
|
||||||
<div class="control-group input-title">
|
<div class="control-group input-title">
|
||||||
<label class="control-label muted"><%= t("personal_journal.author") %></label>
|
<label class="control-label muted"><%= t("personal_journal.author") %></label>
|
||||||
<div class="controls">
|
<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" %>
|
<%= f.hidden_field :member_profile_id, value: (@journal_paper.member_profile_id ? @journal_paper.member_profile_id : ""), id: "member_value" %>
|
||||||
</div>
|
</div>
|
||||||
|
@ -311,8 +311,6 @@
|
||||||
<%= f.submit t('submit'), class: 'btn btn-primary' %>
|
<%= f.submit t('submit'), class: 'btn btn-primary' %>
|
||||||
<%= link_to t('cancel'), get_go_back, :class=>"btn" %>
|
<%= link_to t('cancel'), get_go_back, :class=>"btn" %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<%= render 'author_autocomplete'%>
|
<%= render 'author_autocomplete'%>
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|
Loading…
Reference in New Issue