Tag: jquery chaining

jQuery .animate / .each chaining

我正在尝试将匹配的东西组合起来: $(“.item”).each(function(i) { //animation here }); 使用jQuery固有的链接function,强制动画等待上一个动画完成,例如: $(“.item”).each(function(i) { $(this).animate({marginLeft:”0″}, 60); }); 然后在动画完成后触发.load函数。 基本上,我想按顺序淡出四个项目[一个接一个,而不是一次全部],然后将四个新项目加载到同一个div中,替换前四个。 我怎么能以可重用/可变的方式做到这一点?

将Bootstrap选项卡链接到服务器URL

看起来已经有很多讨论,但我无法让我的代码工作。 我有一个Django项目和带有Bootstrap tab药片的模板。 我试图将标签菜单药片绑定到我的Django项目的url。 我只是无法读取Uncaught Error: Syntax error, unrecognized expression: /employee_user_info/40/客户端错误。 这是我的代码: HTML: {{person_details_form.second_nm_rus.value}} {{person_details_form.first_nm_rus.value}} {{person_details_form.middle_nm_rus.value}} Tab 1 Tab 2 Tab 3 Django urlconf url(r’^employee_user_info/(?P\d+)/$’,employee_views.profile_user_info, name =’employee_user_info’), JS var navpills = $(‘.nav-pills’); $(function () { // activate tab on click navpills.on(‘click’, ‘a’, function (e) { var $this = $(this); // prevent the Default behavior e.preventDefault(); […]

编写一个返回值的jQuery插件

我正在编写一个jQuery插件,在某些情况下存储一些数据。 我想以一种非常灵活的方式编写它,我可以更改输入参数以获取插件存储的某些值。 说明: 当我调用$(“#any”).myPlugin() ,我的插件初始化创建一个div而一些内部。 单击a将使用.data()方法存储.index() 。 如果我调用$(“#any”).myPlugin(“getSelection”)那么我想用.data()获取存储的值。 我尝试过的: (function ($) { $.fn.myPlugin = function (action) { if (action == null) action = “initialize”; return this.each(function ($this) { $this = $(this); if (action == “initialize”) { $this.html(”); var div = $(“div”, $this); div.append(‘A’).append(‘B’).append(‘C’); div.children(“a”).each(function (i) { $(this).click(function (event) { // Here I store the index. […]

Jquery承诺链

我有一个简单的事件链: 从metaData表中获取列(异步) 加载选定的列(异步) 渲染列表 我曾经只是链接这些函数,每个函数在完成后调用它们。 然而,它不是很明显(在填充视图时调用getColumnsFromMeta结果)。 因此,为了清晰和重用代码,我想使用JQuery Promises重构它们。 我之前使用过承诺。 但是我如何连锁超过两个? getColumnsFromMeta ().then(loadSourceFromDatabase /*some arguments*/) //.then(renderList)?; 以下是getColumnsFromMeta的示例: var getColumnsFromMeta = function(id) { var sql, dfd; dfd = $.Deferred(); var onSuccess = function(tx, result) { var columns = []; for (var i = 0; i < result.rows.length; i++) { columns.push(result.rows.item(i).Column); } dfd.resolve(columns); }; var onError = function(tx, […]