Confirm before delete malfunctioning - css

I have two repositories for the same project (long story - I'm trying to learn well, so I wanted to do it again for good measure). In one project, there is a confirm message before deleting, and there's a glyphicon trashcan on the delete button as well. In the other (current) one, neither the confirm message nor the trashcan are working (but the song does indeed delete).
The main issue here is not the trashcan, but rather that data { confirm: ... } is not working.
In the working version, the code looks like this:
<td><%= button_to delete_song_path(song_id: song.id), data: { confirm: "Are you sure?" }, class: 'btn-mini btn-danger btn' do %>
<i class="glyphicon glyphicon-trash"></i>
<% end %></td>
In the other non-working version, the code looks like this:
<td><%= button_to destroy_user_song_path(#song), data: { confirm: "Aight, are you sure?" }, class: 'btn-mini btn-danger btn' do %>
<i class="glyphicon glyphicon-trash"></i>
<% end %></td>
For the trashcan, I did some "reverse elimination" of the working version, and found that although I have all the same bootstrap gems downloaded, the line of code that made the trashcan stay / go away was `#import "bootstrap-sprockets";' in application.css.scss. However, doing the same thing in the other project didn't work, so it must be the fact that in the working version, there are glyphicon files in the public-fonts file. If that's the culprit, I'll deal with that later once I have all the other base functionality down.
Thanks!

I'm going to go ahead and answer this since I got it to work: I'm not 100% sure on the exact cause of the problem, but what I do know is that I decided to simplify things and get rid of all bootstrap gems, instead opting to use a CDN file from netdna.bootstrap.com for bootstrap 3.3.7, and everything fixed itself.
So in sum, simple seems to be the best way to go for those like me who have little to no experience. As a side note, I also defined a helper file in the helper directory in order to define a variable for the bootstrap version. This way, in the future I can switch versions of bootstrap by simply replacing the variable with the correct version.

Related

Rails 4 - Bootstrap themes and crazy CSS

I have a rails 4 app.
I've been struggling for MONTHS to figure out how to incorporate a bootstrap theme. I thought using a design template might help me structure my content, but it is causing me a world of pain. I just can't figure out how to work with it.
Everything has been incorporated into the pipeline, but now I have instances of CSS that isn't in my code, being imposed.
For example, in my new user registration form, I have a submit button that has:
<div class="form-actions">
<%= f.button :submit, "Sign up", :class=>'btn btn-info' %>
</div>
The info button is blue. When I load the page, it shows with now background colour.
When I load localhost and inspect the element, I get this:
<input type="submit" name="commit" value="Sign up" class="btn btn-default btn btn-info">
The btn btn-default is not part of my code, but somehow it is being imposed.
Does anyone know how to solve this problem. I've torn my hair out for weeks trying to figure this out.
MORE INFO:
When I inspect the code, it shows the attributes of btn btn-info as struck out. I understand this to mean that a closer CSS tag has overridden that element, but the tag that inserts that CSS tag is the last in the list. How can there be anything closer? And if there is something, why doesn't it show in the inspector?
Are you using simple_form ? If so, take a look in your config/initializers/simple_form.rb (or simple_form_bootstrap.rb if you used the flag --bootstrap at the generation, which I think you did)
By default, Simple Form apply a specific wrapper (see documentation here to make your own).
If you just need this one button, either way, you have to specify it like so :
<%= f.input :username, input_html: { class: 'btn btn-info' } %>
You have the same helper for the generated label :
<%= f.input :username, label_html: { class: 'my_class' } %>
Now, for a button, apparently doing simply this should do the trick (according to the documentation):
<%= f.button :submit, "Custom Button Text", class: "btn btn-info" %>
Don't hesitate to have a look at the (well made) documentation here (once again, assuming you use Simple Form :-) )
Check simple_form_bootstrap.rb in your initializers and remove 'btn-default' class from
SimpleForm.setup do |config| config.button_class = 'btn btn-default'
Use e.g. your own style there - if you want it applied for all buttons. Alternatively, make this option an empty string and apply individual specific classes for each separate button:
<%= f.button :submit, class: "btn btn-specific" %>
The config value is added to button classes here
I don't see easy way to remove this class output for single specific control. Either remove it globally or override selectors for this style in your case.
See this - you can't individually remove btn-default class - need to remove it in general config file if you need

liferay-ui:search-container-column-button wont react to click

i am using liferay-ui:search-container-column-button inside liferay container the button should point to another jsp with take parameter from the current selected row.
<liferay-ui:search-container emptyResultsMessage="There are no organizations available">
<liferay-ui:search-container-results
results="<%=OrganizationLocalServiceUtil.getOrganizationAll() %>"
total="<%=OrganizationLocalServiceUtil.getOrganizationsCount() %>">
</liferay-ui:search-container-results>
<liferay-ui:search-container-row
className ="fff.sem.service.model.Organization"
keyProperty="organizationId"
modelVar="organization"
escapedModel="<%=true %>"
>
<liferay-ui:search-container-column-text
name="Organization short name"
value="<%= organization.getOrganizationShortName() %>">
</liferay-ui:search-container-column-text>
<liferay-ui:search-container-column-text
name="Organization full name"
value="<%= organization.getOrganizationFullName() %>">
</liferay-ui:search-container-column-text>
<liferay-ui:search-container-column-button href="<%=addOrganization1URL %>"></liferay-ui:search-container-column-button>
<liferay-ui:search-container-column-jsp
align="right"
path="/html/sem/organization_actions.jsp"
/>
</liferay-ui:search-container-row>
As you noticed in the code I used search-container-column-jsp to add edit and delete feature for the row. I use a column with search-container-column-button so that each button of that column point to another form, but the search-container-column-button wont react on clicking. What is going on?
Recent Liferay forum posts indicate a potential issue with the taglib:
search-container-column-button does not work
Issue in calling an action from liferay search-container-column-button tag
grep of the Liferay source code nor a github search return a single instance where the taglib is used.
My attempts to use the <liferay-ui:search-container-column-button to properly call any type (action, render, resource) URL were not successful. In examining the source closer, I believe the generic dump of the href attribute value into the onclick attribute is the problem.
In comparing the html generated by a <aui:button> to that of the search-container-column-button the onclick attribute is missing location.href=
I would recommend using a liferay-ui:search-container-column-jsp as you have done for the other actions, but instead of an icon-menu use a <aui:button> if you want the field to be a button.
Including the missing info:
<%
final String hrefFix = "location.href='" + addOrganization1URL .toString()+"'";
%>
<liferay-ui:search-container-column-button href="<%=hrefFix%>"/>
does provide a working solution, however, if this is indeed a bug and is fixed in a future patch, this workaround would then become a bug.

Image Hyperlink in ASP.NET - MVC 4

I try to create a project for the first time in asp.net (mvc4).
and what i try to do is to create a image which is a hyperlink to go to the index page.
i have search a lot of things and it shows very simple to do that.
but i can´t understand why it doesn´t work for me.
someone can give a hand?
Code:
<a href="<%= Url.Action("Index","Home")%><img src="~/Content/imagens/nav-arrow-back.png"/></a>
The Action is "Index" in the controller calls Home.
you miss a quote
<a href="<%=Url.Action("Index","Home")%>"> ...
^
about this quote you missed
For bad request, fix the whole <img> part
<img src="<%=Url.Content("~/Content/imagens/nav-arrow-back.png")%>"/>
First up, as previously noted you're missing a closing quote on that href. Second, MVC 4 doesn't use the <% %> syntax, at least not by default; it should be using Razor v2 which uses #, so your code should look like this:
<img src="~/Content/imagens/nav-arrow-back.png"/>
If you use the old syntax I assume it would try to handle the actual text <%= Url.Action("Index","Home")%> as a URL, which clearly won't work.

Rails 3 Ajaxful_rating Styling Issue

I'm using the ajaxful_rating gem for a user rating system in my rails app and I came across a weird styling issue:
As you can see there's much too many stars, there shouldn't be more than 5. I used Ajaxful_rating before in a previous app and didn't run into this problem. I recently started using Twitter Boostrap but as far as I can tell there aren't any styling conflicts as I removed every css link except the one needed for ajaxful_rating and I had the same issue.
Here's my view:
<dl>
<% Upload.by_ratings.limit(5).each do |upload| %>
<dt><%= link_to truncate(upload.name, :length => 55), upload%></dt>
<dd><%= upload.user.username %> - <%= ratings_for upload, :static %></dd>
<% end %>
</dl>
Has anybody ran into this problem before?
The problem was that I was directly linking to the css in my layout. I had forgotten that I needed to call the helper method ajaxful_rating_style instead.
place <%= ajaxful_rating_style %> in your javascripts.

How do i get rid of __o is not declared?

I have some code in my master page that sets up a a hyperlink with some context sensitive information
<%If Not IsNothing(Profile.ClientID) Then%>
<span class="menu-nav">
<a target="_blank"
href=
"http://b/x.aspx?ClientID=<%=Profile.ClientID.ToString()%>&Initials=<%=Session("Initials")%>"
>
Send
<br />
SMS
<br />
</a>
</span>
<%End If %>
<span class="menu-nav"> <!-- Name __o is not declared Error is flagged here-->
Now the issue seems to be in the href part. If I remove the dynamic code the error disappears. Can anyone tell me how to resolve this issue?
I've found the answer on the .net forums. It contains a good explanation of why ASP.Net is acting the way it is:
We have finally obtained reliable repro and identified the underlying issue. A trivial repro looks like this:
<% if (true) { %>
<%=1%>
<% } %>
<%=2%>
In order to provide intellisense in <%= %> blocks at design time, ASP.NET generates assignment to a temporary __o variable and language (VB or C#) then provide the intellisense for the variable. That is done when page compiler sees the first <%= ... %> block. But here, the block is inside the if, so after the if closes, the variable goes out of scope. We end up generating something like this:
if (true) {
object #__o;
#__o = 1;
}
#__o = 2;
The workaround is to add a dummy expression early in the page. E.g. <%="" %>. This will not render anything, and it will make sure that __o is declared top level in the Render method, before any potential ‘if’ (or other scoping) statement.
An alternative solution is to simply use
<% response.write(var) %>
instead of
<%= var %>
Yes, I have experienced the same bug occasionally in pages that use server side constructs on ASPX pages.
Overtime, I found a fix for it (I'm sorry, I just haven't been able to find out where I found this bit of info again.) and that fix is to put the following code above the errant <%...%> block:
<%-- For other devs: Do not remove below line. --%>
<%="" %>
<%-- For other devs: Do not remove above line. --%>
Apparently, where you put the above code makes all the difference to VS.NET, so it may take a few tries to get it right.
This is an odd solution, but for me I managed to fix this problem by simply closing the offending open files in Visual Studio.
With them open, i was erratically getting the __o problem.
As soon as I closed them, the __o problem disappeared.
After some hours of googling and analyzing bunch of aspx'ses in my current project seems I've found the solution, that is working for me. Would to advise strongly avoid html-style comments:
<!-- ... -->
inside aspx page. Instead of it use aspx-style comments
<%-- ... --%>
Additionally it helped me obtain that vs intellisense and code highlighting became working again and the mainly thing - this case had begun from it - vs can now hit the breakpoints inside embedded pieces of vb/cs code! And no any damn "This is not a valid location for a breakpoint" message.
When I've cleaned the solution, restarted IIS and it is still mysteriously playing up, I find this can sometimes be caused by pasting an ASPX source file's contents from another system into Visual Studio which "helpfully" updates the code, possibly changing some IDs and breaking the page.
Pasting it into another editor (Notepad++?) then saving it stops Visual Studio from "being helpful" and the page works again.

Resources