Gmaps4rails + Infobox : Remote links fail

154 Views Asked by At

Each marker on my map has an infowindow.

If I use the Infobox plugin to build the infowindow, remote links inside it process action as "HTML" instead of "JS".

I should precise that everything work well (I mean, action processed as "JS") when I remove the infoboxBuilder.

My code :

var handler = Gmaps.build('Google', {builders: { Marker: InfoBoxBuilder} });

# In the Infowindow : <%= link_to "More", voir_infos_path(t), :remote => true %>
# Log : Started GET "/voir_infos/545e1dd382cd47db98000bb9" for 127.0.0.1 at 2014-12-04 23:10:56 +0100
Processing by ObjetsController#voir_infos as HTML

But when I remove the InfoBoxBuilder :

var handler = Gmaps.build('Google');
# Same code in Infowindow : <%= link_to "More", voir_infos_path(t), :remote => true %>
# Log : Started GET "/voir_infos/545e23ae82cd47e5ac000542" for 127.0.0.1 at 2014-12-04 23:13:53 +0100
Processing by ObjetsController#voir_infos as JS

Here the infoboxbuilder.js.coffee I found on stackoverflow :

class @InfoBoxBuilder extends Gmaps.Google.Builders.Marker # inherit from base builder
# override method
create_infowindow: ->
   return null unless _.isString @args.infowindow

boxText = document.createElement("div")
boxText.setAttribute("class", 'yellow') #to customize
boxText.innerHTML = @args.infowindow
@infowindow = new InfoBox(@infobox(boxText))

@bind_infowindow() 

infobox: (boxText)->
  content: boxText
  boxClass: "infoBox box-shadow"
  pixelOffset: new google.maps.Size(-140, -380)
  closeBoxURL: ""
  boxStyle:
    width: "280px"

How could I make it work ? Thanks

EDIT

I have this link in each Infowindow : <%= link_to "More", voir_infos_path(t), :remote => true %> which should process ObjetsController#voir_infos as "JS", isn't it ?

When I use the Infobox plugin to display the infowindow (with this part of code : builders: { Marker: InfoBoxBuilder} and click on "More", :remote => true doesn't work, and ObjetsController#voir_infos is processed as "HTML" instead as "JS".

When I remove builders: { Marker: InfoBoxBuilder}, everything work well, and when I click on "More", ObjetsController#voir_infos is processed as "JS".

EDIT 2 :

The HTML generated for the Infowindow :

<div class="infoBox box-shadow" style="width: 280px; position: absolute; visibility: visible; left: 132.270229334012px; top: 72.179231562186px; cursor: default;"><div class="yellow"><div class="row iw-content">
<div>
    <img src="/covers/max_creer/missing.png">
</div>
<div class="small-12 columns">
    <div class="row">
        <div class="small-12 columns">
            <h6> Maison Bloc </h6>

        </div>

    </div>
    <div class="row">
        <div class="small-12 columns">
            <a href="/voir_infos/545e1de582cd47db98000d91"  data-remote="true">More</a>
        </div>
    </div>
</div>

0

There are 0 best solutions below