fix for profile comment editing

This commit is contained in:
Kyle Drake 2019-06-28 15:08:22 -07:00
parent 54a27a23ed
commit c5d0194946
2 changed files with 9 additions and 11 deletions

View file

@ -1,24 +1,24 @@
var ProfileComment = { var ProfileComment = {
displayEditor: function(eventId) { displayEditor: function(eventId) {
var commentDiv = $('#event_'+eventId+' div.title div.comment') var commentDiv = $('#event_'+eventId+' div.content')
var eventActions = $('#event_'+eventId+'_actions') var eventActions = $('#event_'+eventId+'_actions')
eventActions.find('a#editLink').css('display', 'none') eventActions.find('a#editLink').css('display', 'none')
commentDiv.html(Template.template($('#comment-edit-template').html(), {eventId: eventId, content: commentDiv.text()})) commentDiv.html(Template.template($('#comment-edit-template').html(), {eventId: eventId, content: commentDiv.text()}))
$('#event_'+eventId+' div.title div.comment').text() $('#event_'+eventId+' div.title div.comment').text()
}, },
cancelEditor: function(eventId) { cancelEditor: function(eventId) {
var eventActions = $('#event_'+eventId+'_actions') var eventActions = $('#event_'+eventId+'_actions')
var commentDiv = $('#event_'+eventId+' div.title div.comment') var commentDiv = $('#event_'+eventId+' div.content')
eventActions.find('a#editLink').css('display', 'inline') eventActions.find('a#editLink').css('display', 'inline')
commentDiv.text(commentDiv.find('textarea').text()) commentDiv.text(commentDiv.find('textarea').text())
}, },
update: function(eventId, csrfToken) { update: function(eventId, csrfToken) {
var eventActions = $('#event_'+eventId+'_actions') var eventActions = $('#event_'+eventId+'_actions')
var commentDiv = $('#event_'+eventId+' div.title div.comment') var commentDiv = $('#event_'+eventId+' div.content')
var self = this var self = this
console.log(commentDiv.find('textarea').val()) console.log(commentDiv.find('textarea').val())
$.post('/event/'+eventId+'/update_profile_comment', { $.post('/event/'+eventId+'/update_profile_comment', {
@ -29,4 +29,4 @@ var ProfileComment = {
self.cancelEditor(eventId) self.cancelEditor(eventId)
}) })
} }
} }

View file

@ -21,6 +21,4 @@
<a href="/site/<%= site.username %>?event_id=<%= profile_comment.event.id %>"><%= profile_comment.created_at.ago %></a> <a href="/site/<%= site.username %>?event_id=<%= profile_comment.event.id %>"><%= profile_comment.created_at.ago %></a>
</span> </span>
</div> </div>
<div class="content"> <div class="content"><%== sanitize_comment profile_comment.message %></div>
<%== sanitize_comment profile_comment.message %>
</div>