Skip to content

Instantly share code, notes, and snippets.

@neokoenig
Created April 23, 2015 08:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neokoenig/69a389545b1d44c13569 to your computer and use it in GitHub Desktop.
Save neokoenig/69a389545b1d44c13569 to your computer and use it in GitHub Desktop.
<script>
var gm=$("#mycanvas").gridmanager({
// Add the custom button
customControls: {
global_col: [{ callback: 'insert_image', loc: 'top', iconClass: 'fa fa-file-image-o' }]
}
}).data('gridmanager');
// Function which gets called
function insert_image(container, btnElem) {
// In this instance, I'm getting a remote AJAX HTML fragment to populate bootbox.js dialog
$.ajax({url: "/admin/imagemanager/dialog",
success: function(data){
// Bootbox modal call
bootbox.dialog({
// Populate bootbox with data from ajax call
message: data,
title: "Image Manager",
buttons:{
success: {
label: "Insert Image",
className: "btn-success",
// This is th
callback: function(e){
var selectedImage=$("#image-dialog").find(".image-dialog-selected");
selectedImage.data({imageSize: $("#image-size").val()});
var sc="[image src='"
+ selectedImage.data("imageName")
+ "'"
+ " size='"
+ $("#image-size").val()
+ "' caption='"
+ selectedImage.data("imageCaption")
+ "']";
// This bit is the key - it adds an editable region with the string I want to insert already in it
gm.addEditableAreaClick(container, btnElem, sc);
}
}
}
});
}
});
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment