隐藏的Bootstrap模式不会触发(Bootstrap modal on hidden does not trigger)
就像标题所说我有问题要运行modal.on('hidden')事件。 我可以毫无问题地打开模态。 使用它的代码看起来像这样:
var info = $('<img src="img/icons/info.png">'); info.attr('data-toggle','modal'); info.attr('data-target','#infoPopup');
模态本身看起来像这样:
<div class="modal fade" id="infoPopup" role="dialog"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">×</button> <h4 id="popupHeader" class="modal-title"></h4> </div> <div id="popupBody" class="modal-body"> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> </div> </div> </div> </div>
它开得很好但是当我通过点击模式旁边的关闭按钮或右上角的X来关闭它时,似乎隐藏的事件不是触发器。
$('.modal.in').on('hidden',function(){ console.log('test'); });
当我尝试使用
$('.modal.in')
在控制台上访问它时,所选的模态是正确的。 所以我不是想在错误的模态上得到一个回调。 我也尝试用$('.modal.in').on('hidden.bs.modal',func...)
。 但我得到了同样的结果。谢谢你的帮助。
Like the title says i have problem to getting the modal.on('hidden') event to run. I can open the modal without any problems. The code im using for it looks something like this:
var info = $('<img src="img/icons/info.png">'); info.attr('data-toggle','modal'); info.attr('data-target','#infoPopup');
The modal itself looks like this:
<div class="modal fade" id="infoPopup" role="dialog"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">×</button> <h4 id="popupHeader" class="modal-title"></h4> </div> <div id="popupBody" class="modal-body"> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> </div> </div> </div> </div>
It Opens perfectly fine but it seems like the hidden event is not triggert when I'm closing it by clicking beside the modal the close button or the X on the top right.
$('.modal.in').on('hidden',function(){ console.log('test'); });
The selected modal is the correct one when i'm trying to access it on the console with
$('.modal.in')
. So i'm not trying to get a callback on the wrong modal. I also tried it with$('.modal.in').on('hidden.bs.modal',func...)
. But i got the same result.Thanks for your help.
原文:https://stackoverflow.com/questions/35454352
最满意答案
您可以通过获取第一个值来聚合名称。
In [283]: df.groupby('email').agg({'price': sum, 'quantity': sum, 'name': 'first' ...: }) Out[283]: price name quantity email a@a.com 5.30 alan 2 b@a.com 4.99 barbara 2
或者,您可以将名称聚合成一个字典。
In [281]: df.groupby('email').agg({'price': sum, 'quantity': sum, 'name': lambda x ...: : x.value_counts().to_dict()}) Out[281]: price name quantity email a@a.com 5.30 {u'alan': 1} 2 b@a.com 4.99 {u'barbara': 2} 2
或者,如果您要添加为字符串。
In [282]: df.groupby('email').agg({'price': sum, 'quantity': sum, 'name': sum }) Out[282]: price name quantity email a@a.com 5.30 alan 2 b@a.com 4.99 barbarabarbara 2
但是,对于您的电子邮件名称组合相同的特定情况,您可以使用Igor Raush的建议
df.groupby(['name', 'email'], as_index=False).sum()
You could aggregate, names by taking the first value.
In [283]: df.groupby('email').agg({'price': sum, 'quantity': sum, 'name': 'first' ...: }) Out[283]: price name quantity email a@a.com 5.30 alan 2 b@a.com 4.99 barbara 2
Or, you could aggregate names into a dict.
In [281]: df.groupby('email').agg({'price': sum, 'quantity': sum, 'name': lambda x ...: : x.value_counts().to_dict()}) Out[281]: price name quantity email a@a.com 5.30 {u'alan': 1} 2 b@a.com 4.99 {u'barbara': 2} 2
Or, if you were looking to add as string.
In [282]: df.groupby('email').agg({'price': sum, 'quantity': sum, 'name': sum }) Out[282]: price name quantity email a@a.com 5.30 alan 2 b@a.com 4.99 barbarabarbara 2
But, for a specific case where your email-name combination is same, you can go with Igor Raush's suggestion
df.groupby(['name', 'email'], as_index=False).sum()
相关问答
更多-
使用Python Pandas将所有列与通配符名称搜索进行汇总(Sum all columns with a wildcard name search using Python Pandas)[2021-09-09]
我找到了答案。 使用这个问题的数据,数据框: from pandas import * P1Channels = data.filter(regex="P1") P1Sum = P1Channels.sum(axis=1) I found the answer. Using the data, dataframe from the question: from pandas import * P1Channels = data.filter(regex="P1") P1Sum = P1Channels ... -
IIUC: df_out = pd.concat([df.set_index('Build'),df.set_index('Build').agg(['max','min','mean'])]).rename(index={'max':'Max','min':'Min','mean':'Average'}).reset_index() 输出: index Avg Min Max 0 BuildA 56.1900 39.123000 60.1039 ...
-
Python用于groupby的sum操作,但排除非数字数据(Python for sum operation by groupby, but exclude the non-numeric data)[2020-12-21]
我认为你需要带有参数errors='coerce'的数字来转换非数字到NaN ,然后groupby + sum省略这些行: df = (pd.to_numeric(df['#Line_Changed'], errors='coerce') .groupby(df['filename']) .sum() .to_frame() .add_prefix('SUM ') .reset_index()) print (df) ... -
Agg将字典作为各种格式的参数。 edf2 = e2.resample('W').agg({"Category":'size',"Sales":'sum'}) Agg takes a dictionary as arguments in various formats. edf2 = e2.resample('W').agg({"Category":'size',"Sales":'sum'})
-
仅在数字数据的情况下在Pandas的剪辑上获取无法排序的类型(Getting unorderable types on Pandas' clip on column with only numerical data)[2022-03-06]
我认为你误解了df.clip的使用 - 它意味着将异常值符合某个特定的外边界,而不是删除它们。 来自文档的一个例子: df 0 1 0 0.335232 -1.256177 1 -1.367855 0.746646 2 0.027753 -1.176076 3 0.230930 -0.679613 4 1.261967 0.570967 df.clip(None, 0.5) 0 1 0 0.335232 -1.256 ... -
如何从java中输入的字符串中删除所有非数字字符?(How to remove all non-numerical characters from a string input in java?)[2023-08-20]
您可以使用此方法将字符串转换为仅数字: public String getNumericString(String ourString) { StringBuilder neededCharacters = new StringBuilder(); //Read throught the entire length of your input string for(int i = 0;i使用由to_numeric + isnull创建的掩码的boolean indexing 注意:此解决方案未找到或过滤保存为字符串的数字:例如“1”或“22” print (pd.to_numeric(df['num'], errors='coerce')) 0 -1.48 1 1.70 2 -6.18 3 0.25 4 NaN 5 0.25 Name: num, dtype: float64 print (pd.to_numeric(df['num'], errors= ...如何先移动它然后将它们加在一起? In [223]: def my_rolling_sum(d, n): .....: g = d.groupby(level='IDX_1') .....: return np.sum([g.shift(i) for i in range(n)]) .....: 让我们看看表现: In [224]: df = mul_df(1000,25,1000) In [225]: timeit df.groupby(level='IDX_1') ...您可以通过获取第一个值来聚合名称。 In [283]: df.groupby('email').agg({'price': sum, 'quantity': sum, 'name': 'first' ...: }) Out[283]: price name quantity email a@a.com 5.30 alan 2 b@a.com 4.99 barbara 2 或者,您可以将名称聚合成一个字典。 In [28 ...IIUC你可以做到以下几点: In [103]: df.groupby(level=0).diff().fillna(df).reset_index() Out[103]: name day no 0 Jack Monday 10.0 1 Jack Tuesday 30.0 2 Jack Wednesday 50.0 3 Jill Monday 40.0 4 Jill Wednesday 110.0 所以groupby第一 ...相关文章
更多- Select2在Bootstrap 3 Modal框中不能搜索的解决方法
- BootStrap入门教程 (四)
- BootStrap入门教程 (三)
- Bootstrap3与artDialog绝配搭建图书管理系统
- BootStrap入门教程 (一)
- BootStrap入门教程 (二)
- Bootstrap响应式网页布局视频教程
- Bootstrap视频教程-宁皓网:Bootstrap 网页设计用户界面架构
- Bootstrap基础视频教程-尚学堂视频教程
- 顶 Opencart &Bootstrap&Android&IOS&JsonRPC&微信公众平台
最新问答
更多- 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
- 如何通过引用返回对象?(How is returning an object by reference possible?)
- 矩阵如何存储在内存中?(How are matrices stored in memory?)
- 每个请求的Java新会话?(Java New Session For Each Request?)
- css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
- 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
- xcode语法颜色编码解释?(xcode syntax color coding explained?)
- 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
- 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
- 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
- 西安哪有PLC可控制编程的培训
- 在Entity Framework中选择基类(Select base class in Entity Framework)
- 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
- 电脑二级VF有什么用
- Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
- 金华英语角.
- 手机软件如何制作
- 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
- 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
- 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
- Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
- 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
- python的访问器方法有哪些
- DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
- 在Ruby中对组合进行排序(Sorting a combination in Ruby)
- 网站开发的流程?
- 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
- 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
- 透明度错误IE11(Transparency bug IE11)
- linux的基本操作命令。。。