Ideas on jQuery window.send_to_editor with custom textarea?
I am using 'shortcodes ultimate', you can click a button next to the
wordpress media uploader. When you select your shortcode it is inserted
with window.send_to_editor.
This is great, but I am having a hard time figuring out how to write it so
that I can use it with multiple custom text-area's.
I inserted the button above each text-area, most likely I am going to need
to modify the code, here is an example of what I have in mind.
My code working adjusting due to multiple text-areas and buttons (just
wrote this up now, not sure if this is the proper approach)?
$('#generator-insert').each(function() {
$(this).live('click', function(event) {
//Lots of code here to build up the values, not needed for this
example
var shortcode = jQuery('#generator-result').val();
//Perhaps an if statement using the class the click came from here
if ($(this).attr('class') == 'send_to_editor') {
window.send_to_editor(shortcode);
} else {
// Not quite sure what to write here to send to the text-area
which the
// click came from, I should look up "window" and write
something here.
// I just am a little lost and need some helpful insight...
}
});
});
Here is the original version
$('#generator-insert').live('click', function(event) {
//The generated value data here not needed for this question
var shortcode = jQuery('#generator-result').val();
// Insert into widget
if ( typeof window.generator_target !== 'undefined' ) {
jQuery('textarea#' + window.generator_target).val(
jQuery('textarea#' + window.generator_target).val() + shortcode);
tb_remove();
}
// Insert into editor
else {
window.send_to_editor(shortcode);
}
// Prevent default action
event.preventDefault();
return false;
});
One thing I do note here is window.generator_target I feel like this is
how you insert it into a custom area. Not quite sure and would love some
help.
No comments:
Post a Comment