Extjs 4.1 Check Change Listener

What is the right way to handle menu check items events ?

I have this menu:

{ xtype: 'button', id: 'types_btn', autoWidth: true, text: 'Types', menu: { xtype: 'menu', frame: true, id: 'types_menue', items: [ { xtype: 'menucheckitem', id: 'f_type', text: 'first', listeners: { checkchange: { fn: me.onFirstButtoncheckchange, scope: me } } }, { xtype: 'menucheckitem', id: 's_type', text: 'second', listeners: { checkchange: { fn: me.onSecondButtoncheckchange, scope: me } } }

Then the functions:

onFirstButtoncheckchange: function(menucheckitem, checked, options) { var t = Ext.getCmp('f_type'); if (t.checked) goToFunction(???); . . }, onSecondButtoncheckchange: function(menucheckitem, checked, options) { var t = Ext.getCmp('s_type'); if (t.checked) goToFunction(???); . . },

1- Is there anyway to use one listener and gather all different functions in it ?

2- How can I send the current item to goToFunction() as you see in the code ?


Just make an handler for each menu check item:

items: [{ xtype: 'menucheckitem', text: 'select all' , id: 'first' , listeners: { checkchange: me.myHandler } },{ xtype: 'menucheckitem', text: 'select specific' , id: 'second' , listeners: { checkchange: me.myHandler } }]

And your handler defined as follows:

myHandler: function (menucheckitem, checked, opts) { switch (menucheckitem.getId ()) { // Here handles the first case 'first': if (checked) { console.log ('First checked!'); goToFunction (); } break; // Here handles the second case 'second': if (checked) { console.log ('Second checked!'); goToFunction (); } break; default: console.log ('Whatever!'); } }


Looks like the listener doesn't get triggered quite often. You can use checkHandler config instead.


  • jQuery Uncaught TypeError with Theme Punch Revolution Slider
  • Overriding a jQuery Core function in javascript - getJSON
  • setTimeout in a JQuery animation
  • How do I center a div in the middle of the page using jQuery and keep it centered when window is re-
  • Best way to put delay after calling javascript functions
  • “conflicting implementations for trait” when trying to be generic
  • How to handle & return both properties AND functions missing in a Python class using the __getat
  • Problems with sorting by date (dd.mm.YYYY) in Datatable using Moment.js and Ordering Plugin
  • javascript scroll to bottom of div class
  • How to setup embedded master/master replication with OrientDB?
  • perl - need to add set of lines into a file
  • Pressing 'enter' with multiple input boxes
  • Documentation of NHibernate events and lifecycle?
  • Referencing piped value in Elixir
  • select only 1st level of nested elements
  • File upload field is reset when submit form
  • How to convert the ENUM value to String from view to a controller
  • Elasticsearch field name aliasing
  • Is it possible to create a macro to implement builder pattern methods?
  • C# enable/disable network tracing at runtime?
  • Applying a series of functions to a list
  • 'cannot call methods on tooltip prior to initialization' error when I add the jquery-ui li
  • jquery change text on div
  • RabbitMQ BasicConsume and Event Driven Issues relating to Console.ReadLine()
  • How can I index C arrays in Rust?
  • Download file, filename
  • On change event Ext.form.DateField
  • Pass code to a method as an argument
  • Can you restrict a generic to T where T is a trait implemented by Self?
  • Tensorflow not predicting accurate enough results
  • How to ignore a block of code when transpiling with BabelJs?
  • Sorting is not working in jQuery datatables
  • jQuery.fn.load() is deprecated?
  • Output error rate per label / confusion matrix
  • How to process a big array applying a async function for each element in nodejs?
  • DataTables+RequireJS: Cannot read property 'defaults' of undefined
  • How to emulate integrated numeric keypad cursor keys in linux
  • jQuery file download plugin
  • if some function is not optimized does it mean that all functions where it is declared are not optim
  • Why doesn't a local variable live long enough for thread::scoped?