1

私は次のコードを持っています:

<?php
$this->beginWidget('zii.widgets.jui.CJuiDialog', array(
    'id'=>'mydialog',
    // additional javascript options for the dialog plugin
    'options'=>array(
        'title'=>'Confirmar',
        'resizable'=>'false',
        'autoOpen'=>false,
        'modal'=>true,      
        'buttons'=>array('Eliminar'=>'js:function(){deleteMessage();$(this).dialog("close");}',
                         'Cancelar'=>'js:function(){$(this).dialog("close");}',),
    ),
));?>
<div style="display:none">Do you confirm you want to delete the item?</div> 
<?php 
$this->endWidget('zii.widgets.jui.CJuiDialog');
?>

<input type="button" onclick="js:openDlg()" value="Open the dialog">
<script language="javascript" type="text/javascript">
    function openDlg(){
        $("#mydialog").dialog("open"); 
    }
</script>

これは、jQueryの.load()関数を呼び出す必要があるまでは完全に機能します。テストの目的で、.load()メソッドを呼び出すボタンがあります(ただし、ドキュメントの準備ができたら呼び出す必要があります)。この試用ボタンをクリックする前にダイアログを開くボタンを押すと、ダイアログが正しく開きます。それ以外の場合は、次のエラーで失敗します。

$( "#mydialog")。dialogは関数ではありません$( "#mydialog")。dialog( "open");

試用ボタン:

<input type="button" onclick="js:load_wall()" value="Load Messages">
function load_wall(){
        var liga = $("#liga_id").val();
        $('#div_wall_messages').load('displayMessages',{liga_id: liga}, function(){

        });

どうか、どんな助けでも大歓迎です。このエラーは私を夢中にさせています。ありがとうございました!!

4

3 に答える 3

2

なにdisplayMessages?スクリプトが含まれているページですか?jQueryの別のコピーを含むページですか?jQueryの2番目のコピーを含めると、既存のコピーが上書きされます。おそらく、DialogプラグインがロードされているjQueryを、ロードされていない新しいコピーで上書きしている可能性があります。

divにロードする必要があり、ロードされるファイルに含まれるものがHTMLの全ページ(、などを含む<head><script>である場合は、必要なコンテンツのフラグメントのみを(によってid)ロードする必要があります。目標。いずれの場合も、;load()を含むHTMLコンテンツの使用は避けてください。<script>結果は、状況に応じて、何も意味がないか、何も意味がありません。

またjs:、上記のすべてのコードでは何も行わないため、省略する必要があります。

于 2011-08-02T17:51:13.043 に答える
1

If the load is the problem, it's likely that you've loaded (and overwritten) the currently loaded libraries, which might include jQuery with your dialog plugin. Make sure you load a clean page, (Whenever I AJAX, I generally only generate a single <div> or a <ul>, whatever I need, and not the entire webpage.

If that fails, make sure the proper javascript files are included, that include jQuery and seemingly also jQuery UI.

Check in your browser's network/resources tracking what's up with those script files, and see if there are any other error messages (maybe a 404 not found?) on the javascript files.

于 2011-08-02T19:07:59.487 に答える
0

As already explained above, you probably override the libraries.

One way of dealing with it is to ensure that the correct files are loaded.

Another way is to insert an iframe between the dialog and the content in the dialog. Iframes are treated by the browser as a separate page with its own scripts. So the scripts of the content "on top of" the iframe, will be separate from the scripts of the dialog "under" the iframe.

Since you are using Yii, check this wiki.

于 2013-08-01T09:53:20.000 に答える