Created
August 6, 2014 13:54
-
-
Save neokoenig/0112bf45d481283c8f9d to your computer and use it in GitHub Desktop.
Gridmanager save contents to hidden form field using external button
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- The Gridmanager canvas --> | |
<div id="mycanvas" class="clearfix"></div> | |
<!-- The Form--> | |
<form method="post" action="saveme" id="gridmanager-save"> | |
<!-- hidden Field--> | |
<input type="hidden" name="mycontent" id="mycontent" /> | |
<input type="submit" name="submit" class="submit" /> | |
</form> | |
</div> | |
<!--================== JS ================--> | |
<script> | |
$(document).ready(function(){ | |
var gm = jQuery("#mycanvas").gridmanager().data('gridmanager'); | |
$(".submit").on("click", function(e){ | |
canvas = gm.$el.find("#" + gm.options.canvasId); | |
gm.deinitCanvas(); | |
$("#mycontent").val(canvas.html()); | |
$(this).submit(); | |
}); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I came upon a better method to do the above.
In my save function I get the gridmaster data this way now:
That is far easier than my previous post. :)