neokoenig / jQuery-gridmanager

A way of building rows and grids with built in editable regions; requires jQuery, jQueryUI, Bootstrap 3.x, & optional TinyMCE or CKEditor
http://neokoenig.github.io/jQuery-gridmanager/
461 stars 129 forks source link

How to know when new row / Editable-Region is added? #55

Closed KrishnaPG closed 9 years ago

KrishnaPG commented 9 years ago

I need to place default-content (such as some js charts) inside editable region once it is created. How to get notified about new regions being created?

Or, once an editable region is created, I would like the user to click on it to let him select a chart from multiple charts so that the region gets filled with that selected chart. Is this kind of thing possible?

Also, is it possible to know about other events, such as "preview about to be shown" etc. ?

neokoenig commented 9 years ago

For the most control, I'd probably use a custom button: See: http://neokoenig.github.io/jQuery-gridmanager/demo/customcontrols.html for an example.

I often use bootbox.js to trigger a modal which can then be used to insert something in an editable region.

Here's a cut and paste of something I use: https://gist.github.com/neokoenig/69a389545b1d44c13569

KrishnaPG commented 9 years ago

Thanks much @neokoenig The bootbox.js pointer is helpful and your code is working.

However, now we have "Add Editable Region" redundant button, I need to get rid of (since we have new custom image insertion button). I guess we would have to hide it (with display:none) right?

Is it not possible to add click handler / callback to that "Add editable region" button directly (instead of adding another button and hiding the in built one).

And how to handle the "preview" button? I would like to get notified before preview is being launched.

KrishnaPG commented 9 years ago

Ok, I guess gm.options.editableRegionEnabled that covers the redundant button part.

Still wondering about getting notified for the preview handler part.

neokoenig commented 9 years ago

editableRegionEnabled: false as you've seen should do the trick.

If you want to trigger something on the preview part, you could just do

  $("button.gm-preview").on("click", function(e){
  alert("foo"); 
});
neokoenig commented 9 years ago

Closing, but feel free to reopen if required.