多选选择元素 - 在添加/删除新项目之前捕获当前选项集
您好,感谢您的阅读。
我有一个在 SharePoint 2010 中托管的 aspx 表单,该表单内有一些多个选择元素。有一些按钮可以在这些选择元素中添加和删除选项。
我的问题是,每次添加/删除新选项时,我都需要根据这些多选元素中的选项运行查询。 SharePoint 正在执行一些我无权访问的服务器端代码,但这是我的根本问题。
如果我挂钩按钮的 onclick 事件,则当调用我的函数时,选项已添加到选择元素或从选择元素中删除。我需要在 onclick 函数执行之前捕获这些元素的当前选项集。
还有其他我可以参加的活动吗?诸如 onbeforeclick 之类的按钮或多选元素上的 optionsChanged 之类的东西?看起来任何事件都不能满足我在这里需要做的事情,但我希望有人以前遇到过类似的问题。
谢谢,
扎卡里·卡特
Hello and thank you for reading.
I have an aspx form hosted in SharePoint 2010 that has some multiple select elements within a form. There are buttons to add and remove options from these select elements.
My problem is that I need to run a query based on the options within these multi select elements each time new options are added / removed from them. SharePoint is executing some server side code I don't have access to but here's my underlying problem.
If I hook into the buttons' onclick event, when my function is called the options have already been added to or removed from the select element. I need to capture the current option set of these elements, before the onclick function executes.
Is there another event I can tie into? Something like onbeforeclick on the buttons or optionsChanged on the multi select element? It doesn't look like any event will satisfy what I need to do here, but I'm hoping someone has faced a similar issue before.
Thanks,
Zachary Carter
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我能想到的唯一解决方案是每次添加或删除选项时捕获当前的选项集。
然而,这个解决方案将涉及大量的数组操作,如果我可以避免这种情况并简单地在调用按钮的 onclick 事件之前绑定到一个事件,那将是我的理想解决方案。
The only solution I could come up with is to capture the present set of options each time an option is added or removed.
This solution is going to involve alot of array manipulation however, and if I can avoid that and simply tie into an event, before the onclick event of the button is called, that would be my ideal solution.
这可能不是您问题的一个很好的答案,如果不是,我深表歉意。然而,我刚刚遇到了一个非常相似的问题,尽管使用的是 Visual Basic。在我看来,该解决方案并不优雅,但我使用了 VB 的 MouseUp 事件,该事件在释放鼠标按钮时触发。在释放时(即,在上一个操作结束时),我将元素中的所有信息保存到一个数组中,然后在下一次单击时,在发生其他任何事情之前,我可以检查该数组。
编辑:啊,看起来你在我打字时基本上发布了该解决方案。抱歉我没注意到。
This might not be a great answer to your question, and if not, I apologize. However, I just ran into a very similar problem, albeit using Visual Basic. The solution wasn't elegant in my eyes, but I used VB's MouseUp event, which fires when the mouse button is released. On release (i.e., at the end of the previous action), I save all the information in the elements into an array, and then on the next click, before anything else happens, I can check against that array.
Edit: Gah, looks like you posted essentially that solution while I was typing. Sorry I didn't notice.