[ 10 posts ]

JB Malatrasi

  • Username: JumBay
  • Joined: Thu Sep 17, 2009 4:59 am
  • Posts: 23
  • Location: France
  • Twitter: JumBay
  • Offline
  • Profile

Event delegate "change" never fires on IE

Post Posted: Fri Mar 05, 2010 2:25 am
+0-
Hi,

Whenever I apply an Event delegate on inputs change, it never fires on IE.
Ex :

Code:
Y.delegate('change',function(){
    alert("change ok!");         
},document.body,'.inputDelegate');

<div><input type="text" class="inputDelegate" /></div>


You can see an exemple online : http://www.jumbay.info/yui/delegate/

But others events like: click, mousemove,... are working.

Is there a way to solve that (without apply an listener on each elements)?


Thanks.

Satyam

YUI Contributor

  • Username: Satyam
  • Joined: Tue Dec 09, 2008 12:34 am
  • Posts: 2016
  • Location: Sitges, Spain
  • GitHub: Satyam
  • Gists: Satyam
  • IRC: DevaSatyam
  • YUI Developer
  • Offline
  • Profile

Re: Event delegate "change" never fires on IE

Post Posted: Fri Mar 05, 2010 3:16 am
+0-
I am not sure YUI3 can improve that much on what the DOM does not provide:

http://www.quirksmode.org/dom/events/change.html

Bookmark that site, if something doesn't work, it is the place to go and check.

Fiouz

  • Username: Fiouz
  • Joined: Wed Jan 13, 2010 5:03 am
  • Posts: 9
  • Offline
  • Profile

Re: Event delegate "change" never fires on IE

Post Posted: Fri Mar 05, 2010 5:23 am
+0-
I workarounded that problem using "beforeactivate"/"focusout" events and custom attributes:
Code:
                    Y.delegate("beforeactivate", function (event) {
                        var target = event.currentTarget;
                        target.setAttribute("_original_value_", target.get("value"));
                    }, document.body, ".inputDelegate", this);
                    Y.delegate("focusout", function (event) {
                        var target = event.currentTarget;
                        if (target.get("value") !== target.getAttribute("_original_value_")) {
                            this.commentChanged(event); // "this.commentChanged" is a regular event handler
                        }
                    }, document.body, ".inputDelegate", this);


Edit: Use this workaround only if "change" delegation isn't supported:
Code:
                // see http://www.neeraj.name/blog/articles/893

                var eventSupported = function (eventName) {
                    var el = document.createElement("div");
                    eventName = "on" + eventName;

                    var isSupported = (eventName in el);
                    if (!isSupported) {
                        el.setAttribute(eventName, "return;");
                        isSupported = typeof el[eventName] === "function";
                    }
                    el = null;

                    return isSupported;
                };

                if (!eventSupported("change") && eventSupported("beforeactivate") && eventSupported("focusout")) {
                    // INSERT WORKAROUND HERE
                }

JB Malatrasi

  • Username: JumBay
  • Joined: Thu Sep 17, 2009 4:59 am
  • Posts: 23
  • Location: France
  • Twitter: JumBay
  • Offline
  • Profile

Re: Event delegate "change" never fires on IE

Post Posted: Fri Mar 05, 2010 5:35 am
+0-
@Satyam : I've already check this website, and it's wrote that change event is working in IE.

@Fiouz : The event should be supported. I apply it on the input, not on the div. So change event on an input text is supported.

Anyway if I do that:

Code:
<input id="classic" type="text" />
Y.on('change',function(){
   alert("Classic event fire on change");
},'#classic')


The event will fire on IE.

By the way, I tested with the latest jQuery version, and it's working very well.
Check my sample on line, I've update it.

Eric Ferraiuolo

YUI Developer

  • Username: ericf
  • Joined: Mon Jan 12, 2009 8:26 pm
  • Posts: 380
  • Location: Boston, MA
  • Twitter: ericf
  • GitHub: ericf
  • Gists: ericf
  • IRC: eric_f
  • YUI Developer
  • Offline
  • Profile

Re: Event delegate "change" never fires on IE

Post Posted: Fri Mar 05, 2010 9:54 am
+0-
I’m working on a Gallery module to allow bubbling of form events: submit, change, reset. They are pretty tricky in general with the change event being the hardest :-)

Depending on which route I end up taking, the delegate method may/may-not work. Luke Smith wrote the event-synthetic module which I was thinking of using, but that doesn't have support of the delegate method currently.

JB Malatrasi

  • Username: JumBay
  • Joined: Thu Sep 17, 2009 4:59 am
  • Posts: 23
  • Location: France
  • Twitter: JumBay
  • Offline
  • Profile
Tags:

Re: Event delegate "change" never fires on IE

Post Posted: Sat Mar 06, 2010 2:41 am
+0-
Ok, I will watch your gallery module :)

But the fact that this event is not supported in IE, it's a kind of bug.

Scott

  • Username: scottskayak
  • Joined: Tue Aug 23, 2011 1:30 pm
  • Posts: 8
  • Offline
  • Profile
Tags:

Re: Event delegate "change" never fires on IE

Post Posted: Sun Oct 30, 2011 7:13 am
+0-
Has anything been figured out for this problem?
It does not appear that the gallery object has gone anywhere.

Luke Smith

YUI Contributor

  • Username: lsmith
  • Joined: Thu Aug 28, 2008 7:50 am
  • Posts: 507
  • Location: Sunnyvale
  • Twitter: ls_n
  • GitHub: lsmith
  • Gists: lsmith
  • IRC: ls_n
  • YUI Developer
  • Offline
  • Profile

Re: Event delegate "change" never fires on IE

Post Posted: Mon Oct 31, 2011 11:07 am
+0-
http://yuilibrary.com/projects/yui3/ticket/2528683
http://yuilibrary.com/projects/yui3/ticket/2531106
http://yuilibrary.com/projects/yui3/ticket/2526038

Looks like I have some duplicates to mark. But this is on the roadmap for 3.5.0.

Iliyan Peychev

YUI Contributor

  • Username: peychevi
  • Joined: Tue Feb 24, 2009 12:38 pm
  • Posts: 136
  • Location: Varna, Bulgaria
  • Twitter: ipeychev
  • GitHub: ipeychev
  • Gists: ipeychev
  • Offline
  • Profile
Tags:

Re: Event delegate "change" never fires on IE

Post Posted: Tue Nov 22, 2011 1:43 pm
+0-
Hello,

We implemented this feature in AlloyUI library. The code is here.

If you guys are interested, we can contribute it to YUI3.
Please let me know.

Iliyan

lucas theisen

  • Joined: Wed Aug 31, 2011 8:20 am
  • Posts: 2
  • Offline
  • Profile

Re: Event delegate "change" never fires on IE

Post Posted: Fri Aug 17, 2012 10:38 am
+0-
Just a quick update, using http://yui.yahooapis.com/3.5.1/build/yui/yui-min.js, delegate("change",function) works in IE 8 and 9 (didn't test below 8)

---- EDIT ----

Well, now i am using 3.7.2 and it appears it is not working in IE 8... 9 is still ok.
  [ 10 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum