1

In JavascriptMVC's Controller they use the following format for event handling

Instead of classic jquery

$(function(){
  $('#tabs').click(someCallbackFunction1)
  $('#tabs .tab').click(someCallbackFunction2)
  $('#tabs .delete click').click(someCallbackFunction3)
});

they do this

$.Controller('Tabs',{
  click: function() {...},
  '.tab click' : function() {...},
  '.delete click' : function() {...}
})

Is there any way I could set an click event handler for the following jquery selection using their way:

$('#continent_select').siblings("ul:first").find('a').click(function() {
    console.log('here');
});

And if it's not possible, where is the best place to init this handler?

1 Answer 1

0

The $.Controller allows binding of DOM events to its container element and any of its descendants.

It also allows binding events to objects (and can be extended to suit your special needs).

If $('#content_select') matches the element for your controller, then you will not be able to bind elements to its siblings. If it is contained in your controller element, then you have to build the appropiate selector, which by the look of your code could probably look like this:

li:has(#content_select) > ul:first a

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.