小编Has*_*eeb的帖子

为什么我的事件处理程序触发两次?

嘿家伙我有一个艰难的时间试图解决这个问题我已经在3小时仍然无法找出为什么它这样做...这里是代码

private void Catagory_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        int selectedCategoryId = categoryIdList[categoryListBox.SelectedIndex];

        client.GetItemsAsync(selectedCategoryId);
        client.GetItemsCompleted += 
            new EventHandler<GetItemsCompletedEventArgs>(client_GetItemsCompleted);
    }

void client_GetItemsCompleted(object sender, GetItemsCompletedEventArgs e)
{
        itemIdList.Clear();
        itemNameList.Clear();
        itemNumberList.Clear();
        itemDisplayList.Clear(); //Clears the Display List Items

        if (e.Error == null)
        {
            itemIdList = e.ItemIDList;
            itemNumberList = e.itemNumber;
            itemNameList = e.Result;

            for (int i = 0; i < itemIdList.Count; i++)
            {
                itemDisplayList.Add(new ItemDisplay { itemNumber = itemNumberList[i], itemName = itemNameList[i] });
            }

            //Populating the listbox controll with the itemDisplaylist...
            Items.ItemsSource = itemDisplayList;
        }
        else …
Run Code Online (Sandbox Code Playgroud)

c# event-handling windows-phone-7

3
推荐指数
1
解决办法
1万
查看次数

Hammer.js:滑动事件不适用于图像

hammer.js在我的网络应用程序上使用手势功能。我用它来滑动视频元素,效果如预期完美。但是,当我将以下代码应用于图像元素时,它不起作用。

App.Views.Photo = Backbone.View.extend({
template  : template('photoTemplate'),
className : 'photo',
parent    : null,

events: {
    'swipe' : 'swiped',
    // 'pan'    : 'dragged'
},
Run Code Online (Sandbox Code Playgroud)

...

swiped: function(e) {

    this.remove();
    this.parent.newContent(this.model);
},
Run Code Online (Sandbox Code Playgroud)

这个完全相同的代码适用于视频元素,但不适用于图像。我也尝试e.gesture.preventDefault();在滑动功能内进行操作,但这也不起作用。我目前正在 Firefox 上测试该应用程序。

任何帮助将不胜感激。

谢谢

[编辑]:我正在初始化锤子代码如下

render: function() {

    $(this.el).attr('id', this.model.attributes._id);
    this.$el.html( this.template( this.model.toJSON() ) );

    this.$el.hammer();

    return this;
},
Run Code Online (Sandbox Code Playgroud)

javascript backbone.js hammer.js

2
推荐指数
1
解决办法
3512
查看次数