0

使用Gridster,我可以在开始和停止拖动时绑定事件。但是如何将事件绑定到单击项目?我需要能够选择一个项目才能将其删除,或为其设置一些属性。

4

3 回答 3

0

您可以使用 jquery 单击事件来绑定单击元素。这是一个相同的例子。以下是绑定的一般布局。

       $('.layout_block').click(function () {
                //function to set some properties using $(this)
                //setting an identifier to remove the element
       }

layout_block是gridster所有元素的类。

于 2013-01-24T15:15:03.040 回答
0

javascript $(document).on("click", ".layout_block", handler);

为我工作,即使是添加了gridster.add_widget();.

于 2013-06-22T17:06:44.677 回答
0

我有这个工作代码。

$(".gridster ul li button.close").click(function () {
        gridster.remove_widget($(this).parent());
});

所以在我的 Li 元素中,我有一个class=close用于检测点击事件的按钮,我调用小部件方法gridster.remove_widget并传递 html 元素以将其删除。

快乐编码:)

于 2015-01-10T14:09:03.970 回答