简体   繁体   English

C#下拉菜单选择的索引已更改触发jQuery脚本

[英]c# dropdown selected index changed trigger jquery script

I am trying to trigger jquery function when dropdown index is changed. 我试图在下拉索引更改时触发jquery函数。 Since the dropdown is making a postback I have accordion group in which one group is expanded. 由于下拉列表是回发的,所以我有手风琴组,其中一组被扩展了。 On postback I want to preserve that accordion group and leave it open. 在回发时,我想保留该手风琴组并将其保持打开状态。 I want to trigger the jquery script and expand the same accordion group. 我想触发jquery脚本并扩展相同的手风琴组。 On page load I have this script: 在页面加载时,我有此脚本:

  jQuery(document).ready(function () {
              var accordionId = getParameterByName("policy");           
              $('#' + accordionId).collapse('show');
          });     

It checks if there is querystring parameter 'policy' and according to that value the correct accordion is expanded. 它检查是否有querystring参数“ policy”,并根据该值扩展正确的手风琴。 Now since with dropdown postback I don't want to do whole response redirect since I'll lose all the data and selected dropdown values I want to trigger jquery script as well which will open the appropriate accordion. 现在,由于使用下拉回发,因此我不想执行整个响应重定向,因为我将丢失所有数据和选定的下拉值,因此我也想触发jquery脚本,这将打开相应的手风琴。

You can see the accordion markup at this link: twitter bootstrap accordion expand by querystring parameter in asp.net 您可以在此链接上看到手风琴标记: twitter bootstrap手风琴由asp.net中的querystring参数扩展

Thanks in advance, Laziale 在此先感谢Laziale

Use the accordion's activate event to save the current open panel to a cookie. 使用手风琴的Activate事件将当前打开的面板保存到cookie。 Then after a postback, you can read the cookie value and set the open accordion panel appropriately. 然后,在回发之后,您可以读取cookie值并适当地设置打开的手风琴面板。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM