jQuery:问题与现场活动,表单和后退按钮 [英] jQuery: issue with live events, a form and the back button
问题描述
我已经构建了一个相当复杂的小部件,其中包含某种
形式。它有一个表单标签,但是我通过
Ajax等加载了很多东西。无法详细解释它,并且代码太长以至
粘贴在这里。
现在,在一个live('click',function()中我使用了一个表单域
,我正在向隐藏域中写入一对值
这样可以正常工作,因为我可以在生成的代码中看到它们,但是如果我
离开页面然后点击后退按钮,那么这些值就不会再出现。
如果我在实时点击
函数外部的那些字段中写入一些值,当我离开页面并使用后退按钮返回
时,它们仍然存在。 / p>
但是我需要将这些值写入实时
点击函数的隐藏字段中(我将表单的字段值插入
我不知道是什么原因造成的,并且无法找到解决方法,但
(即使我尝试了很多)。
有什么想法?
感谢!
< input type =textid =fooname =foostyle =display:none;/>
而不是
< input type =hiddenid =fooname =foo/>
我绊倒了同一个问题,解决它。
I have build a quite complex widget which contains "some kind of form". It has a form tag, but I'm loading a lot of stuff in there via Ajax etc. Cannot explain it in detail, and the code is too long to paste in here.
Now, in a "live('click', function()" I use for one of the form fields, I'm writing a couple of values into hidden fields of another form. That works fine, as I can see them in the generated code. But if I leave the page and then hit the back button, the values are gone.
If I write some values into those fields outside the live click function though, they are still there when I leave the page and come back using the back button.
But I need to write the values into the hidden fields out of the live click function (I'm inserting values from fields of my form into them).
I don't know what causes this and wasn't able to find a workaround yet (even though I tried a lot).
Any ideas?
Thanks!
Use CSS to hide the input instead of the input type.
<input type="text" id="foo" name="foo" style="display: none;" />
instead of
<input type="hidden" id="foo" name="foo" />
I tripped over the same issue and this seems to resolve it.
这篇关于jQuery:问题与现场活动,表单和后退按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!