2011-03-31 39 views
0

我使用這個joomla方法在我的自定義應用程序中顯示wysiwyg編輯器。Joomla Wysiwyg&jquery發佈問題

// this initiates the wysiwig 

<?php $editor =& JFactory::getEditor(); ?> 

// this displays a text area with the wysiwyg 

<?php echo $editor->display("desc",$desc,'100%','300','20','20','0'); ?> 

我現在要發佈的文本區域的內容了,通過我的內聯jQuery腳本

// SAVE THE FORM DATA 

$('#SAVELISTING').click(function(){ 

if (confirm("Click OK to save the data")) 
{ 

var txt = $.ajax({ 
url: 'update.php', 
async: true, 
type:'POST', 

data:({ 

id:$('input#id').val(), 
listTitle:$('input#listTitle').val(), 
introdesc:$('textarea#introdesc').val(), 
fulldesc:$(JRequest::getVar('textarea#desc')).val() 

}) 

}).success; 
$('.alert').show('slow'); 
} 
}); 

這反過來把它發送到我的update.php腳本。

$desc = mysql_real_escape_string($_POST['fulldesc']); 

DO THE INSERT 

Firebug的迴應,我得到的是JRequest沒有定義

更新


這是正常的方法的Joomla用來發布的數據,任何人都可以也許從這個我怎麼會pst我上面的jQuery代碼中的數據呢?

/*The store-procedure in your model might then look like this*/ 
[...] 
function store() 
{ 
    $row =& $this->getTable(); 
    $data = JRequest::get('post'); 
    /* Get proper HTML-code for your HTML-encoded field now by using JREQUEST_ALLOWHTML*/ 
    $data['yourfieldname']=JRequest::getVar('yourfieldname', '', 'post', 'string', JREQUEST_ALLOWHTML); 
    /* now proceed as suggested */ 

    $row->bind($data); 
    [...] 
    $row->check(); 
    [...] 
    $row->store(); 
    [...] 
} 
[...] 

回答

0

嘗試

fulldesc:$(<?php echo JRequest::getVar('textarea#desc')%>).val() 

看着你更新後,我甚至不能確定你所需要的JRequest電話。嘗試:

fulldesc:$('textarea#desc').val() 
+0

安德魯感謝您的提示,但不幸的是我仍然卡住了。我認爲它與getVAr和價值insard ethe barckets有關,但我不太清楚如何解決它。仍然谷歌搜索.. – jonnypixel 2011-03-31 02:02:46

+0

問題是,你從你的JavaScript調用Joomla函數。我認爲你需要從服務器上的PHP代碼中調用函數,並將結果嵌入到返回給客戶端的JavaScript中。這是正確的嗎? – 2011-03-31 02:24:08

+0

是的,你是對的,它只是想努力工作。我還沒有學習一個框架,所以我使用簡單的PHP,MySQL和一些jQuery來完成這個工作。它的工作原理和我的理解,直到我遇到這樣的問題。 – jonnypixel 2011-03-31 02:55:56