English 中文(简体)
• 如何将价值观论点推向模式。 显示诱杀装置的功能
原标题:How to pass values arguments to modal.show() function in Bootstrap

我有一页显示当地咖啡厅的名单。 当用户点击某个咖啡点时,显示一种模式方言,即已经填满了“咖啡名称”。 该网页载有许多咖啡名称,表格应当包含他点击的“咖啡名称”。

下面是作为连接纽芬兰的文字制作的咖啡名称清单。

         <table class="table table-condensed  table-striped">
      <tbody>   
        <tr>
          <td>B&Js
          </td>
          <td>10690 N De Anza Blvd </td>
          <td>
              <a class="btn btn-primary" data-toggle="modal" onClick="$( #createFormId ).modal( show )" >Announce</a>
          </td>
        </tr>

        <tr>
          <td>CoHo Cafe
          </td>
          <td>459 Lagunita Dr </td>
          <td>
              <a class="btn btn-primary" data-toggle="modal" onClick="$( #createFormId ).modal( show )" >Announce</a>
          </td>
        </tr>


        <tr>
          <td>Hot Spot Espresso and Cafe
          </td>
          <td>1631 N Capitol Ave </td>
          <td>
              <a class="btn btn-primary" data-toggle="modal" onClick="$( #createFormId ).modal( show )" >Announce</a>
          </td>
        </tr>

      </tbody>
    </table>

Here is the modal form

<div class="modal hide fade" id="createFormId"">
<div class="modal-header">
    <a href="#" class="close" data-dismiss="modal">&times;</a>
    <h3>Create Announcement</h3>
</div>
<div class="modal-body">
    <form class="form-horizontal" method="POST" commandName="announceBean" action="/announce" >
        <input type="hidden" name="cafeId" value="104" />
        <fieldset>
            <div class="control-group">
                <label class="control-label" for="cafeName">Where I am Coding</label>
                <div class="controls">
                    <input id="cafeName" name="cafeName" class="input-xlarge disabled" type="text" readonly="readonly" type="text" value="B&amp;Js"/>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="date">Date</label>
                <div class="controls">
                    <input type="text" class="input-xlarge" id="date" name="date" />
                    <p class="help-block"></p>
                </div>
            </div>
            <div class="control-group">
                <div class="controls">
                    <input type="submit" class="btn btn-primary" value="create" />
                    <input type="button" class="btn" value="Cancel" onclick="closeDialog ();" />
                </div>
            </div>
        </fieldset>
    </form>
</div>

问题是如何将实际价值纳入模式的“价值”特性?

<input type="hidden" name="cafeId" value="104" />

“how”活动的形式由“浮点”活动启动。

<a class="btn btn-primary" data-toggle="modal" onClick="$( #createFormId ).modal( show )" >Announce</a>
最佳回答

You could do it like this:

<a class="btn btn-primary announce" data-toggle="modal" data-id="107" >Announce</a>

Then use jQuery to bind the click and send the Announce data-id as the value in the modals #cafeId:

$(document).ready(function(){
   $(".announce").click(function(){ // Click to only happen on announce links
     $("#cafeId").val($(this).data( id ));
     $( #createFormId ).modal( show );
   });
});
问题回答

用途

$(document).ready(function() {
    $( #createFormId ).on( show.bs.modal , function(event) {
        $("#cafeId").val($(event.relatedTarget).data( id ));
    });
});

Here s how i am calling my modal

<a data-toggle="modal" data-id="190" data-target="#modal-popup">Open</a>

在这里,我是如何在模式中获得价值。

$( #modal-popup ).on( show.bs.modal , function(e) {
    console.log($(e.relatedTarget).data( id )); // 190 will be printed
});

我想谈谈我是如何这样做的。 在过去几天里,我把我的头部放在如何通过两条参数上,把 parameters锁模式诊断器。 我在任重道后,找到了这样做的简单方式。

我的《模式守则》是:

<div class="modal fade" id="editGroupNameModal" role="dialog">
  <div class="modal-dialog">
    <div class="modal-content">
      <div id="editGroupName" class="modal-header">Enter new name for group </div>
        <div class="modal-body">
          <%= form_tag( { action:  update_group , port: portnum } ) do %>
          <%= text_field_tag( :gid, "", { type: "hidden" })  %>
          <div class="input-group input-group-md">
          <span class="input-group-addon" style="font-size: 16px; padding: 3;" >Name</span>
          <%= text_field_tag( :gname, "", { placeholder: "New name goes here", class: "form-control", aria: {describedby: "basic-addon1"}})  %>
        </div>
        <div class="modal-footer">
          <%= submit_tag("Submit") %>
        </div>
        <% end %>
      </div>
    </div>
  </div>
</div>

这里是改变阴道和名声输入价值的简单 j:

function editGroupName(id, name) {
    $( input#gid ).val(id);
    $( input#gname.form-control ).val(name);
  }

我刚才把浮标事件联系起来:

//                                                                              &#39; is single quote
//                                                                                   ( 1 ,  admin )
<a data-toggle="modal" data-target="#editGroupNameModal" onclick="editGroupName(&#39;1&#39;, &#39;admin&#39;); return false;" href="#">edit</a>

浮点火首先改变了投入箱的价值,因此,当方言高涨时,表格的数值就已经到位。

我希望这能帮助某个人。 乘客。





相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签