Razor view Html.ActionLink icon [closed] - asp.net-mvc

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I need to add an icon near myLink in razor view,
in .html page i use ` Requête optimisée.
Now i have
#Html.ActionLink("Requete optimisée", "Index", "Requete")
Dont know where to add my icon .

I wouldn't use ActionLink and would do the following:
<a href="#Url.Action("Index","Requete")" class="my-link-class">Requete optimisée
<div class="my-icon"><img src="#Url.Content("~/icon.jpg")" alt="Icon Image" /></a>
More code but also more freedom and control over what is going on.

If you want show an icon just put a img tag before your link:
<img src="~/Content/Images/Image.png" />
#Html.ActionLink("Requete optimisée", "Index", "Requete")
And if you want to display image link then use this:
#Html.ActionImage("Requete optimisée", "Requete", "~/Content/Images/Image.png")

Related

Looking for Drag and Drop functionality [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
Could anyone recommend a good Drag-and -Drop framework out of the box ?
Something like this jquery-ui example, where one can drop a set of widgets onto a sort of Dashboard layout page - example using a photo gallery http://jqueryui.com/droppable/#photo-manager
I just recently found this very cool jquery-ui and Bootstrap 3.0 based dynamic layout tool called gridmanager - http://neokoenig.github.io/jQuery-gridmanager/
You can also check out demos here http://neokoenig.github.io/jQuery-gridmanager/demo/
So with this in mind, I'd like to add a drag/drop sidebar which will allow me to drop "gadgets" onto the grid system.
I'm using Kendo UI as well as JQWidgets, but I'm a bit unsure of how to integrate drag/drop onto this gridmanager system.
After adding jquery-ui and gridmanager js/css files to my index page, here's what the code looks like :
<section id="dashboard-view" class="mainbar" data-ng-controller="dashboard as vm">
<section class="matter">
<div id="mycanvas">
<div class="row">
<div class="col-md-6">
<p>Content</p>
</div>
<div class="col-md-6">
<p>Content</p>
</div>
</div>
</div>
</section>
</section>
<script>
$(document).ready(function () {
var gm = $("#mycanvas").gridmanager({ // fluid widths
controlPrepend: "<div class='row-fluid'><div class='col-md-12'><div id='gm-addnew' class='btn-group '>",
rowClass: "row-fluid",
rowSelector: "div.row-fluid",
rowPrepend: "<div class='row-fluid gm-editing'>"
});
$(".myexternalcontrol").on("click", function (e) {
// Example use of internal gridmanager function:
gm.appendHTMLSelectedCols('<p>my content to append to all my selected cols</p>');
});
});
</script>
Again, I'd like to setup a sidebar or topbar of widgets which can be dragged onto each grid section below (see screen shots).
and here's a screen shot of how it renders in my beta website.
Thnks in advance for your advice.
regards,
Bob
I'm one of the authors of gridmanager.js. Firstly, jqueryUI is required by gridmanager, so you've already got the drag/drop functionality on the page. However, GM is already using the draggable/sortable jqueryUI features, so be warned you might get some clashes.
GM actually creates a lot of temp markup (and then strips it out on preview/save) - have a look at the generated source code - you'll see divs of class "gm-editable-region" - might be worth trying to make that class a 'droppable' region (i.e, so other things can be dropped on it). You might have to extend gridmanager's activateCols function in order to 'reactivate' the droppable regions when it's gone through the preview process though.
Good luck - the github issue queue is here https://github.com/neokoenig/jQuery-gridmanager/issues

How to set up clickable boxes (Ruby) [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I need to be able to set up kind of a navigatable menu. So like, there could be three boxes, each one with a number on it, and if you click on one of them it executes a certain code or takes one to another page. I feel dumb for not knowing how to do this, but I have success in everything but this, thanks so much!
It depends on what you want, but simply, you'd need this:
#config/routes.rb
resources :pages
#app/views/elements/nav.html.erb
<% pages = %w(home about contact) %>
<% for page in pages do %>
<%= link_to "Home", page_path(page) %>
<% end %>
You'll be able to style the boxes to look like buttons using CSS

Retaining values even after form submit in ROR [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I am trying to create a simple calculator application .
calculator.html.erb
<input type=text name="operand_one" value="0"></td>
<input type=text name="operand_two" value="0"></td>
.
.
.
<input type=text name="output" value="<% =#result %>"></td>
I am able to get the output correctly but the values of the first two text boxes changes to 0 , I need to know how to retain these values ..
You're hardcoding the value to "0" with this part of the code
value="0"
you could change the lines to
<input type=text name="operand_one" value="#value_one"></td> #etc...
and in your controller
#value_one = 0 unless X
but X depends on how your controller works - do you go to a new action to solve the problem in the calculator? if so you'll have to use the params hash.
Not related to the question, but why are you using text for your calculation fields? and are you hard coding that html or it's just the output?

rails how to declare a variable and store a value in html.erb [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
hi i have a value like this in html.erb
<img src="<%= file.title, file_path(file) %>" alt=""/>
but when I placed the above code it throws an error
SyntaxError in Files#index
the error comes on file_path(file) section . Is there a way to accomplish this ? like declare a variable and assign it to something ?
Though I did not get whay you are trying to achieve but you can try to do it like this
<img src="<%= "#{file.title}, #{file_path(file)}" %>" alt=""/>
You should declare file (a better naming is #file) in the controller action which is associated with this view. There you can do whatever you want with your variable.

Passing a list from a view to a controller? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
I'm a relatively new Rails developer with a heavy Java/C# background and I'm trying to pass multiple time ranges from my view to my controller. For instance, the user could select the time range 9:00am to 11:00am as well as 2:00pm to 4:00pm. The first thing to came to mind was a list of times or a list of key value pairs so that I know when a time range starts and ends. I'm having trouble figuring out how to pass this information to my Rails controller though.
Is there an ideal Rails way of passing a list to a controller?
From Rails Guide http://guides.rubyonrails.org/action_controller_overview.html
request
GET /mytime?t[]=1&t[]=2&t[]=3
in view
<form method="GET" action="mytime">
<select multiple name="t[]">
<option value="1">1:00pm</option>
<option value="2">2:00pm</option>
<option value="3">3:00pm</option>
</select>
</form>
or
<form method="GET" action="mytime">
<input type="text" name="t[]">
<input type="hidden" name="t[]" value="11">
</form>
#in mytime_controller.rb
def index
params[:t] # return Array of values
end
You pass information from a view to a controller via http query string ('get') or form data ('post').
I would consider multi-select dropdown for this case.
Instead of dropdown i suggest you should create a cool for using some jquery plugin that will improve your application's user experience and yes create a rails form and submit it then you can have information in your controller.
Now is you are saving these selected time, that i think you should do then create a model if you haven't already and use form_for else your can use form_tag for your rails application.
Visit Here and find some time picker that suits you need.

Resources