-1

I am trying to get and pass a rel attr to tell which tab to select in a nyro pop up function.

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');

How do I get that number into the callback endShowContent?

Update: This is being used on different links with different rel values

HTML These are 2 links in the DOM I need to get the rel values on the above click function which nyro handles.

<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>
8
  • 1
    That seems ok. What problem are you getting? Commented Oct 20, 2009 at 15:16
  • I am getting 0 for both. Commented Oct 20, 2009 at 15:24
  • Post the html for the <a class="see-all"> element. Commented Oct 20, 2009 at 15:25
  • Are you trying to get the attribute for the first matched element or the attributes of all matched elements? Commented Oct 20, 2009 at 15:36
  • 1
    @matthewb - if it loads onReady, how do you determine which rel attribute should be used? Commented Oct 20, 2009 at 16:10

3 Answers 3

3

Is this right?

  • If the user clicks either link, you want to show it in a modal window with the appropriate tab selected (specified by the rel attribute).
  • When the page loads open a modal window showing /events/manage_guestlist, with the first tab selected (tab 0).

If so, I'd do it like this:

// 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'));
});
Sign up to request clarification or add additional context in comments.

1 Comment

+1 This seems to achieve the questioner's intention. However, you've got your parentheses and curly-brackets mixed up inside the showGuestList function and you should probably be using nyroModalManual method, since the nyroModal method only binds click handlers and doesn't actually show the dialog.
0

Can you not use

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

$(this) should give you the element that the current event was fired from...

1 Comment

No, nyro does not call endShowContent in the context of any element. Check the source yourself: nyromodal.nyrodev.com/js/jquery.nyroModal-1.5.2.js
0

Now, assuming your tabs function would take just one call for each rel-attribute your could try something like this. The each function will ensure you to access one element at a time.

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

guestlist('a.see-all');

1 Comment

This does not work its gets 0 then 1 immediately because of the each.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.