Skip to content

Commit

Permalink
Merge pull request #5 from sman591/prevent-duplicate-textareas
Browse files Browse the repository at this point in the history
Removed cloning of textarea in DOM
  • Loading branch information
toopay committed Jul 13, 2013
2 parents 6ed34fb + 31f9a11 commit 46ac996
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions js/bootstrap-markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,29 +350,17 @@
// Give flag that tell the editor quit preview mode
this.$isPreview = false

// Build the original element
var container = this.$editor.find('div[data-provider="markdown-preview"]'),
cloneEditor = this.$cloneEditor,
oldElement = $('<'+cloneEditor.type+'/>')

$(cloneEditor.attrKeys).each(function(k,v) {
oldElement.attr(cloneEditor.attrKeys[k],cloneEditor.attrValues[k])
})

// Set the editor content
oldElement.val(cloneEditor.content)

// Remove the hidden textarea
container.prev().remove()
// Obtain the preview container
var container = this.$editor.find('div[data-provider="markdown-preview"]')

// Set the editor data
container.replaceWith(oldElement)
// Remove the preview container
container.remove()

// Enable all buttons
this.enableButtons('all')

// Back to the editor
this.$textarea = oldElement
this.$textarea.show()
this.__setListener()

return this
Expand Down

0 comments on commit 46ac996

Please sign in to comment.