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?

4

1 回答 1

0

允许将$.ControllerDOM 事件绑定到其容器元素及其任何后代。

它还允许将事件绑定到对象(并且可以扩展以满足您的特殊需求)。

如果$('#content_select')与您的控制器的元素匹配,那么您将无法将元素绑定到其兄弟姐妹。如果它包含在您的控制器元素中,那么您必须构建适当的选择器,从您的代码的外观来看,它可能看起来像这样:

li:has(#content_select) > ul:first a
于 2013-01-16T14:14:58.357 回答