Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Зависание ввода в поля из-за формы #10

Open
omcg33 opened this issue Feb 9, 2016 · 4 comments
Open

Зависание ввода в поля из-за формы #10

omcg33 opened this issue Feb 9, 2016 · 4 comments

Comments

@omcg33
Copy link

omcg33 commented Feb 9, 2016

Когда создана большая форма ( > 40 полей ) При вводе текста в Input браузер начитает подвисать. Как я выяснил это происходит из-за того что на все (АБСОЛЮТНО ВСЕ!) элементы формы вешаются события keyup, focus.

Зачем? даже на заголовки ( простой текст) нужные для логического разделения формы
!

1
2

@omcg33
Copy link
Author

omcg33 commented Feb 9, 2016

Мощно
form.find('*').keyup(function () {

@omcg33
Copy link
Author

omcg33 commented Feb 9, 2016

В моем конкретном случаи подходит следующее решение ( у меня нет условий на сравнения со словом)

 var main_selector = Rule.all.map(function(rule){return rule.selector.replace(':checked','');}).join(', ');

        //wait 300ms after keyup
        form.find(main_selector).keyup(function () {
            var wait = setInterval(function () {
                    clearInterval(wait);
                    run_rules()
                },
                300)
        });

 //run after every change
        return form.find(main_selector).change(function () {
            run_rules()
        });

@H1D
Copy link
Owner

H1D commented Feb 9, 2016

Спасибо!
И правда, можно ограничить на input,textarea,select,[contentEditable]
Если есть время попробуй сделать PR

@omcg33
Copy link
Author

omcg33 commented Feb 9, 2016

Мой вариант сверху с вытаскиванием селекторов не оправдался. проще повесить события на 3 тип элемента формы и тормоза пропадут

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants