如何将这些 javascript 行从 scriptaculous 更改为 jQuery 语法
我正在重写一个最初构建在 Scriptaculous 之上的帮助器类。我正在转向 jQuery - 然而,我被困在几行中,我需要帮助(见下文): 注意:javascript 代码穿插有 php 变量(符号是一个死的赠品)
声明1
'new Insertion.Before(\'' . $updateContainer . '\', new Element(\'div\', {\'id\': \'' . $updateContainer . '_loading\', \'class\': \'' . $spinnerClass .'\'})); $(\'' . $updateContainer . '_loading\').innerHTML="<h4>Loading ...</h4>";',
声明 2
'$(\'' . $updateContainer . '_loading\').remove();'
I am rewriting a helper class which was originally built on top of Scriptaculous. I am moving to jQuery - however, I am stuck on a couple of lines, that I need help with (see below): Note: the javascript code is interpersed with php variables (the sigils being a dead give away)
Statement 1
'new Insertion.Before(\'' . $updateContainer . '\', new Element(\'div\', {\'id\': \'' . $updateContainer . '_loading\', \'class\': \'' . $spinnerClass .'\'})); $(\'' . $updateContainer . '_loading\').innerHTML="<h4>Loading ...</h4>";',
Statement 2
'$(\'' . $updateContainer . '_loading\').remove();'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我假设
$updateContainer
是包含加载消息的 HTML 元素的 ID。然后,我会这样写语句 1:
第二个语句是:
如果您有大量 AJAX 通信并且需要经常“加载”,那么最好
hide()
它因此您可以稍后使用show()
来显示它,而无需再次创建 HTML。Statement1 将用于创建加载元素,Statement2 使用
hide()
而不是remove()
来隐藏它,Statement3 使用show()
而不是hide()
再次显示它。I'll assume that the
$updateContainer
is ID of the HTML element that contains the loading message.Then, I'd write the Statement 1 like this:
And the second statement is:
If you have a lot of AJAX communication and need the 'Loading' often, it might be better to
hide()
it so you can justshow()
it later instead of creating the HTML again.Statement1 would be uset to create the loading element, Statement2 with
hide()
instead ofremove()
to hide it and Statement3 withshow()
instead ofhide()
to show it again.