Korisim openWYSIWYG za unos novosti na stranicu. Radi kako treba kada na pocetku normalno loadam editor. Znaci kad je sve u .php filu i kad taj file pozovem. Sve je ok.
Sad bi ja stavio tabove. Da je u jednom tabu editor a u drugom tabu da su novosti aktivne i jos jedan sa neaktivnim novostima. Sve to kuzim, tabovi su ok, i ajax odraduje posao i vraca bowseru ono sto trebam. Problem nastaje kad hoću ponovo editr ali preko ajax requesta. Ovako to izgleda
Code:
.....
....
<script type="text/javascript">
function getXMLHTTP()
{ //fuction to return the xml http object
var xmlhttp=false;
try{
xmlhttp=new XMLHttpRequest();
}
catch(e) {
try{
xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e){
try{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e1){
xmlhttp=false;
}
}
}
return xmlhttp;
}
function ajaxreq(strURL, div)
{
var req = getXMLHTTP(); // fuction to get xmlhttp object
if (req)
{
req.onreadystatechange = function()
{
if (req.readyState == 4)
{ //data is retrieved from server
if (req.status == 200)
{ // which reprents ok status
document.getElementById(div).innerHTML=req.responseText;
WYSIWYG.attach('textarea1', full);
WYSIWYG.attach('textarea2', full);
}
else
{
alert("There was a problem while using XMLHTTP:\n");
}
}
}
req.open("GET", strURL, true); //open url using get method
req.send(null);
}
}
</script>
<script type="text/javascript" src="scripts/wysiwyg.js"></script>
<script type="text/javascript" src="scripts/wysiwyg-settings.js"></script>
<script type="text/javascript">
WYSIWYG.attach('textarea1', full);
WYSIWYG.attach('textarea2', full);
</script>
....
...
<div id="news_content" style="">
Short news:
<textarea id="textarea1" name="text1" style="margin-left: 20px; width:95%; height:200px;margin-bottom:20px;" >
<?=$content?>
</textarea>
<br>
<br>
News detail:
<textarea id="textarea2" name="text2" style="margin-left: 20px; width:95%; height:600px;margin-bottom:20px;" >
<?=$content_detail?>
</textarea>
</div>
.....
....
<script type="text/javascript">
function getXMLHTTP()
{ //fuction to return the xml http object
var xmlhttp=false;
try{
xmlhttp=new XMLHttpRequest();
}
catch(e) {
try{
xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e){
try{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e1){
xmlhttp=false;
}
}
}
return xmlhttp;
}
function ajaxreq(strURL, div)
{
var req = getXMLHTTP(); // fuction to get xmlhttp object
if (req)
{
req.onreadystatechange = function()
{
if (req.readyState == 4)
{ //data is retrieved from server
if (req.status == 200)
{ // which reprents ok status
document.getElementById(div).innerHTML=req.responseText;
WYSIWYG.attach('textarea1', full);
WYSIWYG.attach('textarea2', full);
}
else
{
alert("There was a problem while using XMLHTTP:\n");
}
}
}
req.open("GET", strURL, true); //open url using get method
req.send(null);
}
}
</script>
<script type="text/javascript" src="scripts/wysiwyg.js"></script>
<script type="text/javascript" src="scripts/wysiwyg-settings.js"></script>
<script type="text/javascript">
WYSIWYG.attach('textarea1', full);
WYSIWYG.attach('textarea2', full);
</script>
....
...
<div id="news_content" style="">
Short news:
<textarea id="textarea1" name="text1" style="margin-left: 20px; width:95%; height:200px;margin-bottom:20px;" >
<?=$content?>
</textarea>
<br>
<br>
News detail:
<textarea id="textarea2" name="text2" style="margin-left: 20px; width:95%; height:600px;margin-bottom:20px;" >
<?=$content_detail?>
</textarea>
</div>
to radi. Ne radi kad pozovem ovako
Code:
onclick="ajaxreq('get_editor.php?news=45', 'news_content');"
//getEditor.php
.....
.....
Short news:
<textarea id="textarea1" name="text1" style="margin-left: 20px; width:95%; height:200px;margin-bottom:20px;" >
<?=$content?>
</textarea>
<br>
<br>
News detail:
<textarea id="textarea2" name="text2" style="margin-left: 20px; width:95%; height:600px;margin-bottom:20px;" >
<?=$content_detail?>
</textarea>
onclick="ajaxreq('get_editor.php?news=45', 'news_content');"
//getEditor.php
.....
.....
Short news:
<textarea id="textarea1" name="text1" style="margin-left: 20px; width:95%; height:200px;margin-bottom:20px;" >
<?=$content?>
</textarea>
<br>
<br>
News detail:
<textarea id="textarea2" name="text2" style="margin-left: 20px; width:95%; height:600px;margin-bottom:20px;" >
<?=$content_detail?>
</textarea>
Odradi mi sve( prikaže textarea, popuni ih sa podacima i sve se čini ok, samo nemam WYSIWYG editora.
Nešto mi fali a ne znam šta.