Skip to content

Commit

Permalink
Merge pull request #33 from userabuser/issue-30
Browse files Browse the repository at this point in the history
Fix issue #30 - when in source code view, saving blanks out canvas (requ...
  • Loading branch information
neokoenig committed Jul 27, 2014
2 parents c74d820 + 6becbce commit 245a142
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/gridmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -1148,10 +1148,25 @@
* @returns null
*/
gm.cleanup = function(){
// cache canvas
var canvas=gm.$el.find("#" + gm.options.canvasId);

var canvas,
content;

// cache canvas
canvas = gm.$el.find("#" + gm.options.canvasId);

/**
* Determine the current edit mode and get the content based upon the resultant
* context to prevent content in source mode from being lost on save, as such:
*
* edit mode (source): canvas.find('textarea').val()
* edit mode (visual): canvas.html()
*/
content = gm.mode !== "visual" ? canvas.find('textarea').val() : canvas.html();

// Clean any temp class strings
canvas.html(gm.cleanSubstring(gm.options.classRenameSuffix, canvas.html(), ''));
canvas.html(gm.cleanSubstring(gm.options.classRenameSuffix, content, ''));

// Clean column markup
canvas.find(gm.options.colSelector)
.removeAttr("style")
Expand Down

0 comments on commit 245a142

Please sign in to comment.