8
votes

Twitter Bootstrap Modal apparaît sur l'initialisation

JS
@using (Ajax.BeginForm("CreateUser", "User", null, options, new { style = "margin-bottom:0;" }))
{
    <div style="padding: 20px;">
    <div style="text-align: right; font-size: .7em;">Press Esc to Close</div>
    <h2>New User</h2>
    @Html.LabelFor(m => m.UserName)
    @Html.TextBoxFor(m => m.UserName, new { })
    @Html.ValidationMessageFor(m => m.UserName)
    @Html.LabelFor(m => m.Password)
    @Html.PasswordFor(m => m.Password, new { })
    @Html.ValidationMessageFor(m => m.Password)
    @Html.LabelFor(m => m.Email)
    @Html.TextBoxFor(m => m.Email, new { })
    @Html.ValidationMessageFor(m => m.Email)
    </div>
    <div class="form-actions" style="margin-bottom:0;">
        <input class="btn btn-primary" type="submit" value="Save" />
    </div>
}


1 commentaires

M'a pris pour toujours pour comprendre cela (je suis nouveau à bootstrap). Mais vous n'avez pas besoin d'initialiser aucun modal dans votre code de script, sauf si vous souhaitez personnaliser un modal.


4 Réponses :


12
votes

Ce code n'est pas ce code:

<a class="btn fade" data-toggle="modal" href="#CreateUserModal" >Launch Modal</a>


0 commentaires

13
votes

pour bootstrap 2.0

Définissez l'option "Afficher" sur FALSE CELA comme ceci. P>

$('#myModal').modal({show: false});


1 commentaires

C'est la meilleure réponse en termes d'obtention de la boîte de dialogue de ne pas afficher sur INIT.



8
votes

Cela fonctionne dans FF:

<div id="myModal" class="modal hide">...</div>


0 commentaires

4
votes

Vous pouvez faire un nouveau modal de son constructeur, alors vous avez Ultimate Strort> Control et peut manipuler l'objet modal comme vous voulez.

// Create a new modal object
var modal = new $.fn.modal.Constructor();

// Set whatever defaults you want
$.fn.modal.defaults = { show: true, backdrop: 'static' };
$('#your_el').modal()
  .show()
  .on('hide', function() {
    callbackFunction();
  });


0 commentaires