 	edit: (element, index) ->
 		index = this.getEditingIndex(element) if not index?
 
-		message = this.getMessageOfElement(element)
+		message = this.getMessageById element.getAttribute("id")
+
 		hasPermission = RocketChat.authz.hasAtLeastOnePermission('edit-message', message.rid)
 		editAllowed = RocketChat.settings.get 'Message_AllowEditing'
 		editOwn = message?.u?._id is Meteor.userId()

		if k is 27 # Escape
			if this.editing.index?
				record = this.getMessageDraft(this.editing.id)
				if this.input.value is record?.original
					this.clearCurrentDraft()
					this.clearEditing()
				else
					this.resetToDraft this.editing.id

				event.preventDefault()
				event.stopPropagation()


	recordInputAsDraft: () ->
		id = this.editing.id

		message = this.getMessageById id
		record = this.records[id] || {}
		draft = this.input.value

		if(draft is message.msg)
			this.clearCurrentDraft()
		else
			record.draft = draft
			this.records[id] = record

	getMessageDraft: (id) ->
		return this.records[id]

