Migrating Existing Projects to Salesforce DX
Identifying conflicts with package folders during a Salesforce DX migration.
The code below renders the image above, which for all intents and purposes looks great and works exactly how I imagined…except that the dropdown javascript code has an event that closes the dropdown when clicked. This behavior is not ideal when you are looking to fill out a form, and a click into one of the text fields closes your form.
<a class=”btn dropdown-toggle” data-toggle=”dropdown” href=”#”>Login<span class=”caret”></span></a>
<ul id=”dropdown-login” class=”dropdown-menu” style=”padding: 5px 10px 0px 10px;”>
<%= form_for(“user”, :url => user_session_path) do |f| %>
<li>
<div class=”control-group”>
<%= f.label :login, :class => “control-label” %>
<div class=”controls”>
<%= f.text_field :login %>
</div>
</div>
</li>
<li>
<div class=”control-group”>
<%= f.label :password, :class => “control-label” %>
<div class=”controls”>
<%= f.password_field :password %>
</div>
</div>
</li>
<li>
<div class=”control-group”>
<%= f.label :remember_me, :class => “control-label” %>
<div class=”controls”>
<%= f.check_box :remember_me %>
</div>
</div>
</li>
<li>
<%= f.submit “Sign in”, :class => “btn btn-primary” %>
</li>
<% end %>
</ul>
Fortunately, it is pretty easy to stop this from occurring by stopping the click event from bubbling up. By creating a click handler on my “dropdown-login” tag, I was able to stop the propagation of the event, which allowed my form to work as desired.
// Prevent closing the sign in form on click
j$(‘#dropdown-login’).click(function(e) {
e.stopPropagation();
);