javascript - Uncaught TypeError: object is not a function (calling onchange function) -
my code big maintain short. tring fire onchange event of select atribute. problem when fire got error:
uncaught typeerror: object not function
since code big show codes decalare onchange event , when fire it.
here when onchange function declared:
function e(b, c) { function a() { if (b.current_modal) { b.current_modal.classname = "hide" } f("overlay").classname = "hide" } jigsaw.ui.close_lightbox = a; util.$("overlay").click(a); util.$("set-parts").change(function () { if (this.parts != 9) { jsaw.set_image("images/puzzle.jpeg") } else { jsaw.set_image("images/puzzle1.jpeg") } c.emit(jigsaw.events.parts_number_changed, +this.value); c.emit(jigsaw.events.render_request) }); util.$("game-options").click("a", function (h) { if (jigsaw.events[this.id]) { h.preventdefault(); c.emit(jigsaw.events[this.id]) } }) }
and here when fire onchange event:
show_time: function () { /*.....*/ javascript: document.getelementbyid("date").innerhtml = scoreresult; document.getelementbyid("set-parts").selectedindex = 1; document.getelementbyid('set-parts').onchange(); }
i don't utilize jquery, in javascript there difference on how addeventlistener(eventname, ...) , on*eventname* = function(){} works.
i suppose not modern library utilize on*eventname* interface 1 simple reason: can hold single listener. on*eventname* still there back upwards legacy code.
now, in particular case, when add together event library using addeventlistener/removeeventlistener/dispatchevent underline dom interface. not set legacy on*eventname* property callback, way can straight phone call it dispatching event dom method dispatchevent (or library wrapper) event object type 'change'. "new event('change')" does. if need pass properties event can create this:
new event('change', { foo : 1, bar : 'hello, world!' })
and properties available in listener callback arguments[0] under whichever name set argument (in case, left empty).
javascript jquery html
No comments:
Post a Comment