Rails display two modals from same view -
i have rails view 2 icons. each icon should open different modal (using partial).
the issue both icons opening same modal (the first one).
here code display modals:
<a data-toggle="modal" href="#workorder-<%= workorder.id %>"> <i class="icon-list"></i><%= workorder.wologs.count %> <%= render :partial => "wologs/history", locals: {workorder: workorder} %> </a> <a data-toggle="modal" href="#workorder-<%= workorder.id %>"> <i class="icon-ok-sign"></i><%= workorder.tasks.count %></a> <%= render :partial => "tasks/taskslist", locals: {workorder: workorder} %> </a>
thanks help!
as mryoshiji mentioned reason 2 links point same id, same modal launched.
i add it's incorrect put modal body inside link, if partial modal body.
according bootstrap example:
<a href="#mymodal" role="button" class="btn" data-toggle="modal">launch demo modal</a> <!-- modal --> <div id="mymodal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="mymodallabel" aria-hidden="true"> </div>
the link , modal 2 totally different divs.
so fix is:
launch partial in different div , assign different ids them.
Comments
Post a Comment