Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jquery变量问题?_Jquery - Fatal编程技术网

jquery变量问题?

jquery变量问题?,jquery,Jquery,我正在尝试获取并传递一个rel attr,以告知在nyro弹出函数中选择哪个选项卡 function guestlist (selector) { $(selector).nyroModal({ hideContent: newHide, endShowContent: function () { var getNumbers = $(selector).attr('rel'); alert(getNumbe

我正在尝试获取并传递一个rel attr,以告知在nyro弹出函数中选择哪个选项卡

function guestlist (selector) {
    $(selector).nyroModal({
        hideContent: newHide,
        endShowContent: function () {
            var getNumbers = $(selector).attr('rel');
            alert(getNumbers);
            specialwater();
            tabs('#manage-guestlist',getNumbers);
        }
    });    
}

guestlist('a.see-all');
如何将该号码输入回叫endShowContent

更新: 这在具有不同rel值的不同链接上使用

HTML 这是DOM中的两个链接,我需要在上面的click函数中获取nyro处理的rel值

<a  href="/events/manage_guestlist" class="see-all" rel="1">See All</a>
<a  href="/events/manage_guestlist" class="see-all" rel="0">See All</a>

您不能使用

$(this).attr('rel');
$(这)应该为您提供从中触发当前事件的元素…

您不能使用吗

$(this).attr('rel');

$(这)应该为您提供当前事件触发的元素…

现在,假设您的tabs函数对每个rel属性只调用一次,您可以尝试这样的操作。每个函数将确保您一次访问一个元素

function guestlist (selector) {
    $(selector).nyroModal({
        hideContent: newHide,
        endShowContent: function () {
             $(selector).each(function()
             {
                 tabs('#manage-guestlist', $(this).attr('rel'));
             });
        }
    });    
}

guestlist('a.see-all');

现在,假设您的tabs函数只对每个rel属性调用一次,您可以尝试这样的方法。每个函数将确保您一次访问一个元素

function guestlist (selector) {
    $(selector).nyroModal({
        hideContent: newHide,
        endShowContent: function () {
             $(selector).each(function()
             {
                 tabs('#manage-guestlist', $(this).attr('rel'));
             });
        }
    });    
}

guestlist('a.see-all');
是这样吗

  • 如果用户单击任一链接,您希望在模式窗口中显示该链接,并选择相应的选项卡(由
    rel
    属性指定)
  • 加载页面时,打开一个模式窗口,显示
    /events/manage\u guestlist
    ,选择第一个选项卡(选项卡0)
如果是这样,我会这样做:

// Pass the tab index in to this function
function showGuestList(tabIndex) {
    $('a.see-all').nyroModalManual({
        hideContent: newHide,
        endShowContent: function() {
            specialwater(); 
            tabs('#manage-guestlist', tabIndex);
        }
    });
}

// On page load, nothing's been selected, so show the default tab
$(document).ready(function() { 
    showGuestList(0);
});

// Attach a click handler to our links that passes the value of 
// the element's rel attribute
$('a.see-all').click(function {
    showGuestList($(this).attr('rel'));
});
是这样吗

  • 如果用户单击任一链接,您希望在模式窗口中显示该链接,并选择相应的选项卡(由
    rel
    属性指定)
  • 加载页面时,打开一个模式窗口,显示
    /events/manage\u guestlist
    ,选择第一个选项卡(选项卡0)
如果是这样,我会这样做:

// Pass the tab index in to this function
function showGuestList(tabIndex) {
    $('a.see-all').nyroModalManual({
        hideContent: newHide,
        endShowContent: function() {
            specialwater(); 
            tabs('#manage-guestlist', tabIndex);
        }
    });
}

// On page load, nothing's been selected, so show the default tab
$(document).ready(function() { 
    showGuestList(0);
});

// Attach a click handler to our links that passes the value of 
// the element's rel attribute
$('a.see-all').click(function {
    showGuestList($(this).attr('rel'));
});

看起来没问题。你遇到了什么问题?我两个都得到了0。发布
元素的html。你是在尝试获取第一个匹配元素的属性还是所有匹配元素的属性?@matthewb-如果加载onReady,你如何确定应该使用哪个rel属性?这似乎没问题。你遇到了什么问题?我两个都得到了0。发布
元素的html。你是在尝试获取第一个匹配元素的属性还是所有匹配元素的属性?@matthewb-如果加载onReady,你如何确定应该使用哪个rel属性?否,nyro不会在任何元素的上下文中调用
endShowContent
。自己检查源代码:否,nyro不会在任何元素的上下文中调用
endShowContent
。自己检查来源:这不起作用,因为每个人都会立即得到0然后得到1。这不起作用,因为每个人都会立即得到0然后得到1。+1这似乎达到了提问者的意图。但是,在
showGuestList
函数中,括号和花括号混在一起,您可能应该使用
nyroModalManual
方法,因为
nyroModal
方法只绑定单击处理程序,实际上不显示对话框。+1这似乎达到了提问者的目的。但是,在
showGuestList
函数中,括号和花括号混在一起,您可能应该使用
nyroModalManual
方法,因为
nyroModal
方法只绑定单击处理程序,实际上不显示对话框。