Opened 13 years ago
Last modified 12 years ago
#7941 confirmed New Feature
Fire an event when a template is selected
Reported by: | rekam | Owned by: | |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | General | Version: | 3.0 |
Keywords: | Cc: |
Description
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
Change History (3)
comment:1 Changed 13 years ago by
Keywords: | template select fire event removed |
---|---|
Version: | 3.6.1 (SVN - trunk) → 3.0 |
comment:2 Changed 12 years ago by
comment:3 Changed 12 years ago by
Status: | new → confirmed |
---|
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.
It sounds useful indeed.
Hi rekam
Thanks for the tip, i had the same requirement for a fire templateSelected event, which is solved by you little suggestion.
Thanks. Event.
Replying to rekam: