0

jqueryui ダイアログ ボックスを開いた後、その背景を変更しようとしています。背景色または画像はリンクをクリックした人に固有のものであるため、要件によりスタイルシートでこれを設定できません (背景値はデータベースから取得されます)。

ダイアログがロードされた後に次のjqueryコマンドを実行してdivのcssを変更すると、何もしませんか?

$("#modal_popup_website").css("background","red !important");

また

$("#modal_popup_website .ui-dialog-content").css("background","red !important");

また

$(".ui-dialog-content").css("background","red !important");

私は何を間違っていますか?

まず、次のようにダイアログを初期化します。

$("#modal_popup_website").dialog({
            bgiframe: true,
            autoOpen: false,
            position: 'center',
            width: $(window).width()-30,
            minWidth: 990,
            height: 900,
            minHeight: 900,
            modal: true,
            stack: true, //Puts in front of other dialog's that may be open
            open: function(){

            },
            close: function() {
                //Save
            }

次に、ユーザーが次のようなリンクをクリックすると、ダイアログが開きます。

$("#modal_popup_website").dialog("open");

開いた後、次のような HTML をダイアログ ボックスに入力します。

$("#modal_popup_website").html('gets loaded from external file');

外部ファイルの HTML は次のとおりです。

<div>some text</div>
<script type="text/javascript">
   $("#modal_popup_website").css("background","red !important");
</script>

< script > 領域は、CSS の背景を変更しようとしている場所です。この外部 PHP ファイルで、このユーザーのデータベースから背景色または画像を取得し、ダイアログ ボックスの背景を変更したいのですが、うまくいきません。

どんなアイデアでも大歓迎です!

ありがとう。

4

2 に答える 2

0

私は別の方法で問題を解決することになりました。別の < div > を追加して、幅 100%、高さ 100% にし、css 背景を使用して画像を追加しました。次に、jqueryuiダイアログのスクロールバーを削除し、追加した新しいdivにoverflow:autoを追加しただけで、必要なものが得られました。

于 2013-01-28T23:12:54.997 に答える
0

これを変更する必要があります:

<div>some text</div>
<script type="text/javascript">
   $("#modal_popup_website").css("background","red !important");
</script>

に:

<script type="text/javascript">
    $(document).ready(function() {
        $("#modal_popup_website").css("background","red");
    });
</script>

このリンクが役立ちます: http://css-tricks.com/when-using-important-is-the-right-choice/

于 2013-01-23T18:46:27.010 に答える