如何更改通过“add”添加的 jquery ui 选项卡的 url和“选项卡模板”功能?
我可能会让这件事变得比我需要的更加困难,但我需要一些帮助。我有一些通过添加功能添加的 jquery ui 选项卡。这些选项卡是通过 ajax 实现的。
我在最初添加选项卡时设置了一个 tabTemplate,如下所示。
tabTemplate: "<li><a href='#{href}'>#{label},/a><li>"
添加选项卡功能是通过以下方式完成的:
$tabs.tabs('add', 'http://thanksforyourhelp/greatly/appreciated/, some_title_var)
如果在该选项卡上提交表单,则数据将写入数据库。响应给出添加到数据库的行的 ID。
下次访问该特定选项卡时,链接实际上应该是“http://thanksforyourhelp/greatly/appreciated/ID”,其中 ID 现在已知,因为表单(此处也是 ajax)的响应将其发回。这将根据“ID”数据库中的数据预先填充页面上的表单。
我查看了此处的示例,但我的 href 是相关选项卡的 id (而不是网址)。实际的 url 存储在哪里?
该选项卡看起来像这样。
<a href="#ui-tabs-6">new</a>
我尝试更改其上的 href,但是单击选项卡后,内容将在没有 ajax 的情况下加载,而不是根据需要在选项卡内加载。我在这里可能做错了什么?感谢您的帮助。
编辑:删除引用不再存在的网址的编辑。
I might be making this more difficult than I need to but I am in some need of assistance. I have some jquery ui tabs which are added via the add functionality. these tabs are via ajax.
I have a tabTemplate set as follows on the initial addition of the tabs.
tabTemplate: "<li><a href='#{href}'>#{label},/a><li>"
And the add tab functionality is done via
$tabs.tabs('add', 'http://thanksforyourhelp/greatly/appreciated/, some_title_var)
If a form is submitted on that tab, data is written to the database. The response gives an ID of the row added to the database.
Next time that specific tab is visited the link should actually be 'http://thanksforyourhelp/greatly/appreciated/ID' where the ID is now known since the response from the form (ajax here as well) sent it back. This will pre-populate the forms on the page based off the data in the database for "ID."
I've looked at the example here, but my href is an id for the tab in question (and not a url). Where is the actual url stored?
The tab looks like this.
<a href="#ui-tabs-6">new</a>
I have tried changing the href on that, but upon clicking the tab the content is loaded without ajax instead of within the tab as desired. What might I be doing wrong here? Thanks for your help.
Edit: removed edits with references of no longer existent urls.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我没有太多使用 AJAX 支持的选项卡,但我认为您需要
url
方法:I haven't worked with AJAX-powered tabs too much, but I think you want the
url
method:上面的答案在 JQuery 1.9+ 中不起作用作为描述器 此处。要使用 jquery ui tabs 1.9+,您必须执行类似的操作,
这将更改特定索引处选项卡的 URL 并加载该选项卡。
Above answer will not work in JQuery 1.9+ as describer here. To work with jquery ui tabs 1.9+ you have to do something like this
This will change the URL of tab at particular index and load that tab.