﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
7941	Fire an event when a template is selected	rekam		"Hi,
a nice feature to have would be to fire an event when we click on a template to select it.

I ""forked"" the code like this to do so (very easy indeed):

file: /ckeditor/_source/plugins/templates/dialogs/templates.js
line: 58

{{{
item.on( 'click', function() { insertTemplate( template.html ); } );
}}}

replace with

{{{
item.on( 'click', function(event) {editor.fire('templateSelected', event); insertTemplate( template.html ); } );
}}}

This little thing could be the first step to a ""I-know-which-template-is-used-right-now"" dynamic.

Just as a notice, this is useful in the case you have multiple templates, each with its own css. You select a template, you do a few modification, and send data to server. Then, if the server needs to know which template was selected to fetch the appropriate css, you're screwed.

If an event is fired, at least you can do some work to get the css path. Let's say the template thumb and its css are in the same folder. If you know the thumb's src, you know the css place.

After a clic on the template, you can get the target (event.data.getTarget()) and then browse up to the <table>, then down to the <img> and you're ok.

But that's an other story ^^ . Just the fire('templateSelected') would be very nice!

Thanks"	New Feature	confirmed	Normal		General	3.0			
