SORU
7 EYLÜL 2009, PAZARTESİ


doğal ses olayları değiştirmek

Bir kullanıcı doğal ses bir div düzenlediğinde bir fonksiyonu çalıştırmak istiyorum. Değiştiğinde olay eşdeğer nedir?

Teşekkürler.

Jquery kullanan herhangi bir çözüm tercih edilir jquery kullanıyorum. Teşekkürler!

CEVAP
7 HAZİRAN 2011, Salı


İşte tüm contenteditables on kullanan daha verimli bir versiyonu. Top cevapları buraya dayanıyor.

CoffeeScript jQuery kullanarak:

$('body')
    .on 'focus', '[contenteditable]', ->
        $this = $(this)
        $this.data 'before', $this.html()
        return $this
    .on 'blur keyup paste input', '[contenteditable]', ->
        $this = $(this)
        if $this.data('before') isnt $this.html()
            $this.data 'before', $this.html()
            $this.trigger('change')
        return $this

JavaScript jQuery kullanarak:

$('body').on('focus', '[contenteditable]', function() {
    var $this = $(this);
    $this.data('before', $this.html());
    return $this;
}).on('blur keyup paste input', '[contenteditable]', function() {
    var $this = $(this);
    if ($this.data('before') !== $this.html()) {
        $this.data('before', $this.html());
        $this.trigger('change');
    }
    return $this;
});

Proje şöyle: https://github.com/balupton/html5edit

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

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Jose LviS el Bambino ( JLB )   LviSito

    Jose LviS el

    3 ŞUBAT 2008
  • pendrop gaming

    pendrop gami

    4 ŞUBAT 2013
  • TomSka

    TomSka

    30 Mayıs 2006