Created
April 23, 2015 08:50
-
-
Save neokoenig/69a389545b1d44c13569 to your computer and use it in GitHub Desktop.
This file contains 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
<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