There’s not enough here to really help - there are any number of things that could be going on. It could be a problem with markup, the JavaScript, the spec itself, your spec_helper… My first thought is that your JavaScript is actually replacing more markup than you want it to, but it really could be anything.
My advice to you is to simplify greatly your partial and the JavaScript. Verify the behavior is correct in browser (being sure to check your selectors just as capybara would).