SORU
16 HAZİRAN 2009, Salı


olay.() preventDefault YANİ çalışan değil işlevi.

Aşağıdaki (mootools) javascript kodum:

$('orderNowForm').addEvent('submit', function (event) {
    event.preventDefault();
    allFilled = false;
    $$(".required").each(function (inp) {
        if (inp.getValue() != '') {
            allFilled = true;
        }
    });

    if (!allFilled) {
        $$(".errormsg").setStyle('display', '');
        return;
    } else {
        $$('.defaultText').each(function (input) {
            if (input.getValue() == input.getAttribute('title')) {
                input.setAttribute('value', '');
            }
        });
    }

    this.send({
        onSuccess: function () {
            $('page_1_table').setStyle('display', 'none');
            $('page_2_table').setStyle('display', 'none');
            $('page_3_table').setStyle('display', '');
        }
    });
});

İE hariç tüm tarayıcılarda, bu gayet iyi çalışıyor. Ama YANİ, bu hataya neden. IE8 ben javascript bir hata ayıklayıcı kullanırken, event nesnenin hataya neden olan ve formu teslim oluyor preventDefault bir yöntem olmadığını öğrendim. Bu yöntem firefox durumunda firebug kullanarak öğrendim) desteklenmektedir.

Herhangi Bir Yardım?

CEVAP
16 HAZİRAN 2009, Salı


YANİ, kullanabilirsiniz

event.returnValue = false;

aynı sonucu elde etmek.

Ve bir hata elde etmek için değil, preventDefault varlığı için test edebilirsiniz:

if(event.preventDefault) event.preventDefault();

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Emotional Trancer

    Emotional Tr

    4 Mart 2010
  • infodirt

    infodirt

    11 Mart 2009
  • Jay Will

    Jay Will

    19 NİSAN 2006