altariamx2003
asked on
how to call ajax code from an external js file
I use this code to create jquery dialog and CKEditor instance
I tried to use createeditor() and removeeditor() in an external js file to use them in other file but they doesnt works.
I there way to use my code in an external js file????
<input class="boton_fancybox" onclick="createEditor(this);" id="boton_texto" type="button" style="text-decoration:none;" value="Editar el contenido de este campo">
<textarea rows="5" class="campo" cols="90" id="texto" name="texto" style="display:none;"></textarea>
<script type="text/javascript" src="../../contenidos/ckeditor5/ckeditor.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.0/jquery-ui.min.js"></script>
<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.0/themes/smoothness/jquery-ui.css" />
<script type="text/javascript">
var editor, html = '';
var config = {};
function createEditor(campo)
{
var temp = campo.id.split("_");
if ( editor )
return;
$("#div_"+temp[1]).bind('dialogopen', function() //JQ
{
editor = CKEDITOR.replace( temp[1],
{
height:"600", width:"780",
toolbar: [
{ name: 'document', groups: [ 'mode', 'document', 'doctools' ], items: [ 'Source' ] },
{ name: 'clipboard', groups: [ 'clipboard', 'undo' ], items: [ 'Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo' ] },
'/',
{ name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ], items: [ 'Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat' ] },
{ name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ], items: [ 'NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote' ] },
{ name: 'links', items: [ 'Link', 'Unlink', 'Anchor' ] },
{ name: 'insert', items: [ 'HorizontalRule', 'SpecialChar', 'Iframe' ] },
{ name: 'tools', items: [ 'Maximize' ] },
{ name: 'colors', items: ['TextColor', 'BGColor'] }
],
enterMode : CKEDITOR.ENTER_BR,
shiftEnterMode: CKEDITOR.ENTER_P
});
}).bind('dialogclose', function()
{
removeEditor();//CK
$(this).dialog('destroy');
})
.dialog({autoOpen: false,
maxHeight:0.95 * $(window).height(),//1
width: 800,
modal: false,
position: 'top',
resizable: false,
autoResize: true }).dialog('open');
}
function removeEditor()
{
if ( !editor )
return;
editor.destroy();
editor = null;
}
</script>
I tried to use createeditor() and removeeditor() in an external js file to use them in other file but they doesnt works.
I there way to use my code in an external js file????
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Mr. Simoes you are a genius!!!!!!!!