Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot set HTML options on a Nav link #82

Open
mildred opened this issue Sep 14, 2021 · 2 comments
Open

Cannot set HTML options on a Nav link #82

mildred opened this issue Sep 14, 2021 · 2 comments

Comments

@mildred
Copy link

mildred commented Sep 14, 2021

With the following haml view:

  ui_nav do |nav|
    - nav.link 'text',
    {url: '/url'},
    {'data-method': 'post'}

The data-method attribute is not applied to the <a> element.

Quick demonstration in rails console:

3.0.2 :060 > UiBibz::Ui::Core::Navigations::Nav.new.tap do |n| n.link 'text', { url: '#url' }, { 'data-method': 'post' } end.render
 => "<ul class=\"nav\"><li data-method=\"post\" class=\"nav-item\"><a href=\"#url\" class=\"nav-link\">text</a></li></ul>" 
@mildred
Copy link
Author

mildred commented Sep 14, 2021

There is a problem in the API because there are legitimate cases where we want to add attributes to the <li> element, other cases where we want to add attributes to the enclosing elements. It should be possible to specify multiple html_options for each element we want to ad options for.

@mildred
Copy link
Author

mildred commented Sep 14, 2021

Solution:

3.0.2 :071 > UiBibz::Ui::Core::Navigations::Nav.new.tap { |n| n.link 'text', url: '#url', a_html: { 'data-method': 'post' } }.render
 => "<ul class=\"nav\"><li class=\"nav-item\"><a href=\"#url\" class=\"nav-link\" data-method=\"post\">text</a></li></ul>" 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant