Microsoft AJAX jscript $ find не работает со скрытыми / невидимыми элементами? - PullRequest
2 голосов
/ 25 августа 2011

Microsoft AJAX jscript $ find не работает со скрытыми / невидимыми элементами? Я не могу заставить его работать, но я не знаю, ожидаемое ли это поведение.

Ответы [ 2 ]

4 голосов
/ 25 августа 2011

Если вы установили свойство Visible элемента управления на false, то $find ничего не найдет, поскольку asp.net не генерирует html для элементов управления со свойством Visible, установленным на false. Но это должно работать, если вы используете css / javascript, чтобы скрыть контроль.

0 голосов
/ 25 августа 2011

Вы уверены, что элемент находится в DOM (то есть: Visible = True)?Вот некоторая справочная информация относительно ожидаемого поведения:

$find фактически вызывает findComponent:

Sys.Application = new Sys._Application();
window.$find = Sys.Application.findComponent;

findComponent: function _Application$findComponent(id, parent) {
        /// <summary locid="M:J#Sys.Application.findComponent">Finds top-level components that were added through addComponent if no parent is specified  or children of the specified parent. If parent is a component</summary>
        /// <param name="id" type="String">The id of the component to find.</param>
        /// <param name="parent" optional="true" mayBeNull="true">The component or element that contains the component to find.  If not specified or null, the search is made on Application.</param>
        /// <returns type="Sys.Component" mayBeNull="true">The component, or null if it wasn't found.</returns>
        //#if DEBUG
        var e = Function._validateParams(arguments, [
            {name: "id", type: String},
            {name: "parent", mayBeNull: true, optional: true}
        ]);
        if (e) throw e;
        //#endif
        // Need to reference the application singleton directly beause the $find alias
        // points to the instance function without context. The 'this' pointer won't work here.
        return (parent ?
            ((Sys.IContainer.isInstanceOfType(parent)) ?
                parent.findComponent(id) :
                parent[id] || null) :
            Sys.Application._components[id] || null);
    },
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...