 		if event.which is 13
 			template.open.set false
 
-			value = template.input.value
-			caret = getCursorPosition(template.input)
-			firstPartValue = value.substr 0, caret
-			lastPartValue = value.substr caret
-
-			firstPartValue = firstPartValue.replace(template.selectorRegex, template.prefix + this.getValue(template.value.curValue, template.data.collection) + template.suffix)
-
-			template.input.value = firstPartValue + lastPartValue
-
-			setCursorPosition template.input, firstPartValue.length
+			template.enterValue()
 
 			event.preventDefault()
 			event.stopPropagation()

			Meteor.defer =>
				template.verifySelection()


Template.messagePopup.onRendered ->
	this.input = this.data.getInput?()


		template.value.set this._id

		template.enterValue()

		template.open.set false


