对话框中$ .val()的错误行为 [英] Incorrect behavior with $.val() in dialogs

查看:67
本文介绍了对话框中$ .val()的错误行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我目前正在研究一个使用JQuery和JQuery UI的小项目.我想创建一个对话框,用于编辑表中的某些数据.用户双击一行,然后弹出对话框.这一切都很好,但是当我单击带<a>标签的链接并返回页面时,该对话框的行为很奇怪. $.val("")将不再起作用,并且我也不能通过innerHTML附加html标记或设置文本.

<a>标记执行$.load(),这将在单击时加载页面.

我尝试了很多方法来解决此问题,但到目前为止没有任何效果...
我正在使用JQuery 1.7.2和JQuery UI 1.8.22.

以下是我的代码的最后几个示例,这些示例在通过<a>标记重新加载页面之后,在按钮测试中出错了.
到目前为止,我尝试:
*清空页面容器.
*点击即可重新加载脚本.
*销毁对话框并重新创建.

加载页面的代码:

Hello,

I''m currently working on a small project that makes use of JQuery and JQuery UI. I want to make a dialog that edits certain data in a table. The user double click on a row and the dialog popsup. This all works perfectly but when i click on a <a> tagged link and go back to the page the dialog behaves strange. The $.val("") wont work anymore and neither can i append html tags or set text by innerHTML.

The <a> tag executes $.load() which will load the page on click.

I tried loads of things to fix the issue but nothing works so far...
I''m making use of JQuery 1.7.2 and JQuery UI 1.8.22.

Below are a few examples of my code in the last block it goes wrong at the button test, after the page is reloaded by the <a> tag.

So far i tried to:
* Empty the page container.
* Reload scripts on click.
* Destroy the dialog and recreate it.

Code to load a page:

function LoadPage(pageName) {
    $("#Lym_AdminBodyPage").empty();
    $("#Lym_AdminBodyPage").load(pageName);
}



显示对话框和更改文本的代码:



Code to show the dialog and change text:

$("#dialog").dialog({
        autoOpen: false,
        modal: true,
        buttons: [
        {
            text: "test",
            click: function() {
                var td = $("#edit_mod_uid");
                td.empty();
                var textDiv = document.createElement("div");
                textDiv.setAttribute("id", "edit_mod_uid_div");
                textDiv.innerHTML = CurrentSelectedID;
                td.append(textDiv);
            }
        },
                   {
                       text: "Wijzigigen",
                       click: function () {
                           $(this).dialog("close");
                       }
                   },
                   {
                       text: "Verwijderen",
                       click: function () {
                           $(this).dialog("close");
                       }

                   },
                   {
                       text: "Annuleren",
                       click: function () {
                           $(this).dialog("close");
                       }
                   },

            ],
        open: function () {
        },
        close: function () {

        },
    });

推荐答案

.val(")不再起作用,我也不能通过innerHTML附加html标记或设置文本.

<a>标记执行
.val("") wont work anymore and neither can i append html tags or set text by innerHTML.

The <a> tag executes


.load(),这将在单击时加载页面.

我尝试了很多方法来解决此问题,但到目前为止没有任何效果...
我正在使用JQuery 1.7.2和JQuery UI 1.8.22.

以下是我的代码的最后几个示例,这些示例在通过<a>标记重新加载页面之后,在按钮测试中出错了.
到目前为止,我尝试:
*清空页面容器.
*点击即可重新加载脚本.
*销毁对话框并重新创建.

加载页面的代码:
.load() which will load the page on click.

I tried loads of things to fix the issue but nothing works so far...
I''m making use of JQuery 1.7.2 and JQuery UI 1.8.22.

Below are a few examples of my code in the last block it goes wrong at the button test, after the page is reloaded by the <a> tag.

So far i tried to:
* Empty the page container.
* Reload scripts on click.
* Destroy the dialog and recreate it.

Code to load a page:
function LoadPage(pageName) {


( " ).empty();
("#Lym_AdminBodyPage").empty();


这篇关于对话框中$ .val()的错误行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆