0

How I can add click function in this code, so that in addition to open the submenu also call the filter Links Important?

$('#dl-menu a').ready(function(e) {
    var selector = $(this).attr('data-filter');
    $container.isotope({ filter: selector });
    e.preventDefault();
    e.stopPropagation();
});


$('.dl-submenu a').click(function(e) {
    var selector = $(this).attr('data-filter');
    $container.isotope({ filter: selector });

    e.preventDefault();
    e.stopPropagation();

});
pbaris
  • 4,077
  • 4
  • 36
  • 57

2 Answers2

0

Your issue (based on the current information in the question) is probably due to the use of an ID in the first instance and a class in the second instance.

$('#dl-menu a').ready(function(e) {

$('.dl-submenu a').click(function(e) {

Note that the first item is #dl and the second .dl, correct whichever is wrong and it may fix your issue.

Ryan McDonough
  • 9,202
  • 3
  • 51
  • 73
  • nothing. remains the same. when you select an item from the menu the submenu appears, but not in the filter elements. for example: you click on hotels. appears the submenu to select the type of hotels. but when you click on hotels all hotels should appear and then select the type you want in the submenu. and it is not. and concigo not operate the main menu, because if I put click function does not call the submenu – user2607708 Sep 18 '13 at 14:14
  • Can you post your menu html and js in a JS Fiddle please? – Ryan McDonough Sep 18 '13 at 14:37
0

I'm gonna go out on a branch here...

You're clicking on the menu id="dl-menu a" and you want the filter to be applied while at the same time the submenu to be displayed.

Did you try?

$('#dl-menu a').ready(function(e) {
        var selector = $(this).attr('data-filter');
        $container.isotope({ filter: selector });
        $('.dl-submenu a').show();
        e.preventDefault();
        e.stopPropagation();
    });

I am not sure how the filter applies to your sub-menu.

Edit.... try this:

$('#dl-menu-a').ready(function(e) {
        var selector = $('.dl-submenu a').attr('data-filter');
        $container.isotope({ filter: selector });
        $('.dl-submenu a').show();
        e.preventDefault();
        e.stopPropagation();
    });

Now the filter applies to the submenu attribute and not the menu.

Also I don't think it's good practice to have whietspace (dl-menu a) in your id. I modified it above in my example. It might simply be that whitespace that is your issue.

This thread clearly displays good naming convention What are valid values for the id attribute in HTML?

Community
  • 1
  • 1
mcv
  • 1,232
  • 2
  • 16
  • 39
  • what you have explained is exactly what I want. but I can not – user2607708 Sep 18 '13 at 14:25
  • can you include the html the html snippet in your post. It's really hard to go based upon the javascript you provided. You have an id = dl-menu a, a class = dl-submenu a and an attribute belonging to the dl-menu a. Are you sure that you didn't want the attribute to be applied to the submenu? I'm going to add my edit in the post above. – mcv Sep 18 '13 at 18:19
  • I have jquery.dlmenu.js file. Is that? Html what is only the menu? forgive my ignorance but I'm new at this. – user2607708 Sep 19 '13 at 14:37
  • your example works but I still have the problem of the main menu to select filter elements.you got that first call menu filter elements. but now it does not open the submenu. I think I have only to get submenu call and ready. Do you think you could put some kind of var or add a function? to bring the submenu. – user2607708 Sep 19 '13 at 15:24
  • $('#dl-menu a').click(function(e) { var selector = $(this).attr('data-filter'); $container.isotope({ filter: selector }); e.preventDefault(); e.stopPropagation(); }); $('.dl-submenu a').click(function(e) { var selector = $(this).attr('data-filter'); $container.isotope({ filter: selector }); e.preventDefault(); e.stopPropagation(); }); – user2607708 Sep 19 '13 at 15:24
  • I figured it out lol. I'm happy. was easier than what I thought. thank you very much anyway. $('#dl-menu a').click(function(e) { var selector = $(this).attr('data-filter'); $container.isotope({ filter: selector }); $('#dl-submenu a').addClass("current")(function() { }); e.preventDefault(); e.stopPropagation(); }); – user2607708 Sep 19 '13 at 17:06
  • That is always the case :) – mcv Sep 26 '13 at 16:33
  • Also reviewed your solution there was no way anyone would of been able to assist you without knowing all the parts. You never mentioned any use of CSS styling or the class in your original question. – mcv Sep 26 '13 at 16:37