Rails beginner
Rails beginner

Reputation: 14504

Rails simple-navigation how to put span tag outside link?

In my navigation.rb I have:

primary.item d.slug, d.name + '<span style="background:url(' + root_url + 'images/ikoner/gavekort_konkurrencer.png) no-repeat;"></span>', katshow_path(d.id)

The problem is that the span tag is inside the link.

<li><a href="/10">asdasd<span style="background:url(http://localhost:3000/images.png) no-repeat;"></span></a></li>

How do I put it outside?

So it then would be:

<li><a href="/10">asdasd</a><span style="background:url(http://localhost:3000/images.png) no-repeat;"></span></li>

Upvotes: 2

Views: 353

Answers (1)

Exel Gamboa
Exel Gamboa

Reputation: 946

Maybe you want to write this into your *.html.erb in your views folder:

<li> 
<%= link_to "asdasd", :controller => "10" %> 
<span style="background:url(http://localhost:3000/images.png) no-repeat;"></span> 
</li>

Is the same as:

<li>
<a href="/10">asdasd< /a>
<span style="background:url(http://localhost:3000/images.png) no-repeat;"></span>
</li>

You can chech some other options for your links here: http://apidock.com/rails/ActionView/Helpers/UrlHelper/link_to

Hope it works your you.

Upvotes: 1

Related Questions