Coast Line
asked on
calling textarea on fly in jquery
i have a very classic old HTML javascript editor build in, so i cannot replace it as it is used in whole project,
so here is the code for the editor:
basically this code works as:
<textarea name="abc"></textarea>
<script language="javascript1.2">
editor_generate('abc');
</script>
Now my situation,
I am creating the textarea as such
now what exact changes i need to make to load the editor based textarea rather than normal textarea
so here is the code for the editor:
_editor_url = "";
var win_ie_ver = parseFloat(navigator.appVersion.split("MSIE")[1]);
if (win_ie_ver >= 5.5) {
document.write('<scr' + 'ipt src="' +_editor_url+ 'editor.js"');
document.write(' language="Javascript1.2"></scr' + 'ipt>');
} else { document.write('<scr'+'ipt>function editor_generate() { return false; }</scr'+'ipt>'); }
basically this code works as:
<textarea name="abc"></textarea>
<script language="javascript1.2">
editor_generate('abc');
</script>
Now my situation,
I am creating the textarea as such
$(document).ready(function(){
$('td.edit').click(function(){
$('.myclass').html($('.myclass textarea').text());
$('.myclass').removeClass('myclass');
$(this).addClass('myclass');
$(this).html('<textarea name="textareabox" id="textareabox" style="width:100%;height:100px;vertical-align:top;">' + $(this).text().trim() + '</textarea><br><span>To [Save] Click enter</span>');
$('#textareabox').focusEnd();
}
);
now what exact changes i need to make to load the editor based textarea rather than normal textarea
ASKER
k,
i am doing it like this
var NewLink = document.createElement('sc ript')
NewLink.src="/js/editor.js "
alert(NewLink.src);
editor_generate('textareab ox'); //add your editor call here
but it is giving me an error
ReferenceError: editor_generate is not defined
though i checked the link externally, the editor.js file is there
i am doing it like this
var NewLink = document.createElement('sc
NewLink.src="/js/editor.js
alert(NewLink.src);
editor_generate('textareab
but it is giving me an error
ReferenceError: editor_generate is not defined
though i checked the link externally, the editor.js file is there
Since you're using jQuery try this:
$.getScript("/js/editor.js")
.done(function(script, textStatus) {
console.log( textStatus );
editor_generate('textareabox');
})
.fail(function(jqxhr, settings, exception) {
alert("Triggered ajaxError handler." );
});
ASKER
now another issue, it finds but it keeps reloading the page, happening in firefox and chrome
ASKER
I'd have to see the editor.js code, the "wyciwyg://" (What You See Is What You Get) is most likely is being called by the editor command / code.
ASKER
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks
Open in new window