我在页面上有大约400个元素,它们有点击事件(4个不同类型的按钮,每个按钮有100个实例,每个类型的点击事件执行相同的功能,但参数不同).
我需要尽可能减少对性能的任何影响.通过将点击事件单独绑定到每个(使用JQuery),我采取了什么样的性能(内存等bind())?onclick相反,在每个按钮上调用内联函数会更有效吗?
编辑以澄清:):
我实际上有一个表(使用JQGrid生成),每行有数据列,后跟4个图标'按钮'列 - 删除和其他三个使AJAX调用回服务器的业务函数:
|id|description|__more data_|_X__|_+__|____|____| ------------------------------------------------- | 1|___data____|____data____|icon|icon|icon|icon| | 2|___data____|____data____|icon|icon|icon|icon| | 3|___data____|____data____|icon|icon|icon|icon| | 4|___data____|____data____|icon|icon|icon|icon|
我正在使用JQGrid的自定义格式化程序(http://www.trirand.com/jqgridwsiki/doku.php?id=wiki:custom_formatter)在每行中构建图标"按钮"(我无法从服务器检索按钮HTML).
在我的自定义格式化程序函数中,我可以轻松地在内联中构建图标HTML和代码,onclick使用适当的参数调用相应的函数(来自该行中其他列的数据).我使用行列中的数据作为我的函数的参数.
function removeFormatter(cellvalue, options, rowObject) {
return "<img src='img/favoritesAdd.gif' onclick='remove(\"" + options.rowId + "\")' title='Remove' style='cursor:pointer' />";
}
Run Code Online (Sandbox Code Playgroud)
所以,我可以想到两个选项:
1)内联onclick,如上所述 -
或 -
2)delegate()(如下面的答案所述(非常感谢!))
data()在afterInsertRow JQGrid事件中将图标设置为其参数. delegate()处理程序应用于特定类的按钮(如下文所述@KenRedler) > $('#container').delegate('.your_buttons','click',function(e){
> e.preventDefault();
> var your_param = $(this).data('something'); // store your params in data, perhaps …Run Code Online (Sandbox Code Playgroud) 正如MSDN所说
ConcurrentDictionary<TKey, TValue> Class表示可以由多个线程同时访问的键值对的线程安全集合.
但据我所知,System.Collections.Concurrent课程是为PLINQ设计的.
我有Dictionary<Key,Value>保持服务器中的在线客户端,并且当我有权访问它时通过锁定对象使其成为线程安全的.
我可以放心地取代Dictionary<TKey,TValue>通过ConcurrentDictionary<TKey,TValue>我的情况?更换后性能会提高吗?
这里在第5约瑟夫阿尔巴哈利提到,它专为并行编程
我有一个使用C#在VS2010中编写的Windows窗体应用程序,并在app.config文件中获得以下错误:
Message 4 Could not find schema information for the attribute 'name'
Message 8 Could not find schema information for the attribute 'name'
Message 12 Could not find schema information for the attribute 'name'
Message 5 Could not find schema information for the attribute 'serializeAs'
Message 15 Could not find schema information for the element 'CCP_Utility.Settings1'
Message 2 Could not find schema information for the element 'CCP_Utility.Properties.Settings'
Message 3 Could not find schema information for the element 'setting' …Run Code Online (Sandbox Code Playgroud) 我需要在iTunes连接中创建一个新的应用程序,对于Lite版本?我只是想确定一下,找不到任何文章.
应该怎样一个快速测试一个Windows小工具开发过程中?创建存档,安装存档并每次将其添加到桌面都非常繁琐......
我正在寻找像EurekaLog for Delphi这样的工具,但它适用于Java.
什么是最好的选择?
Ruby中的默认日期格式是yyyy-mm-dd,但在视图中我需要它们为dd/mm/yyyy
我写了一个date_format文件config/initializers:
Time::DATE_FORMATS.merge!( :uk_format => '%m/%d/%Y')
Run Code Online (Sandbox Code Playgroud)
这不起作用,因为我需要打电话date.to_s(:uk_format)才能使用这种格式.但是因为我<%= f.text_field :paymentDate %>用来显示日期,所以我不确定我是否可以添加to_s这个案例.
有人可以帮帮我吗.
编辑1
实际上date.to_s(:uk_format)也不起作用,如何正确使用初始化程序.....?
浏览SubModule教程,我从boto项目中创建了一个子模块.然后,我发现我实际上只需要这个项目的一个子集 - 特别是boto文件夹.
我想更改我的子模块以指向此文件夹.当我查看.gitmodules时,我明白了
[submodule "backup/src/boto"]
path = backup/src/boto
url = https://github.com/boto/boto.git
Run Code Online (Sandbox Code Playgroud)
我应该使用什么URL而不是https://github.com/boto/boto.git?更改URL后,我应该在本地删除boto文件夹并重新拉出吗?
由于某种原因,setItemChecked不起作用.有人可以帮我解决问题吗?
String[] str = getResources().getStringArray(R.array.brush_type);
sizeArrayAdapter = new ArrayAdapter<String>(this.getContext(), R.layout.drawing_list_item, str);
listType = SIZE_LIST;
listView.setAdapter(sizeArrayAdapter);
// Populate the listView
listView.setItemChecked(4,true);
Run Code Online (Sandbox Code Playgroud)
这是列表项:
<CheckedTextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawingCheckedTextView"
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:gravity="center_vertical"
android:checkMark="?android:attr/listChoiceIndicatorSingle"
android:background="@drawable/list_panel"
android:paddingLeft="6dip"
android:paddingRight="6dip"/>
Run Code Online (Sandbox Code Playgroud)
请帮我.
我有一个课程模板Foo<T>.
我想实现一个非成员函数Bar,它需要两个Foos并返回一个Foo.我想Bar成为一名非会员,因为写作者Bar(f1, f2)比写作更自然f1.Bar(f2).我也想Bar成为inline因为计算是微不足道的.
template <typename T>
inline Foo<T> Bar(const Foo<T> &lhs, const Foo<T> &rhs) {
...
}
Run Code Online (Sandbox Code Playgroud)
诀窍是Bar需要访问Foo私人数据.我不希望拥有私有数据的访问者 - 没有充分的理由将私有数据暴露给用户.所以我想结交Bar一个朋友Foo.
template <typename T>
class Foo {
...
private:
T w, x, y, z;
friend Foo<T> Bar(const Foo<T> &lhs, const Foo<T> &rhs);
};
Run Code Online (Sandbox Code Playgroud)
这是我遇到麻烦的地方.编译器抱怨:
当友元声明引用功能模板的特化时,不能使用内联说明符.
这个规则是由标准强加的还是特定于MSVC++?
这是我尝试过的:
创建Bar一个const公共成员函数,然后声明一个简单返回的非成员版本lhs.Bar(rhs).这似乎是最不讨厌的解决方案.
删除inline提示,知道编译器将决定内联而不管提示.这是否会违反单一定义规则?它仍然必须在头文件中定义,因为它是一个函数模板. …