jQuery-Mobile: repeat calls on submit form [closed] - jquery-mobile

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 have two pages in different files A.html & B.html,
A is a listview, B is a form.
On page A, I click one item, then change to page B,
on page B, I submit a form by AJAX, and use ALERT(data) to show result.
I click BACK button return to A.
Question is,
1st round: click submit, alert one time,
2nd round: click submit, alert two times,
3rd round: click submit, alert three times....
How can I fix it?
Thank you

You can execute click event of button like this:
$("#btn_id").on("click", function(event){
if(event.handled !== true)
{
// Your code
event.handled = true;
}
return false;
});

Related

Razor view Html.ActionLink icon [closed]

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")

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

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.

slim dynamic conditional class [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 6 years ago.
Improve this question
Just to help other developers, because there is no similar question on SO.
div class=(is_active? ? 'active' : 'inactive')
div class=('active' if is_active?)
See the examples below:
div class=(is_active? ? 'active' : 'inactive')
div class=('active' if is_active?)
The same approach can be used to assign dynamic values to other attributes.
I use array of classes and nil element if there is no need to include class in list, then compact array to remove nil elements and finally join all together.
div class=(["cday", "col-md-1", day.day == 1 ? "col-md-offset-#{day.cwday-1}" : nil].compact.join(' '))
If you have multiple conditions I am doing right now something like
div class=(('foo ' if is_foo?) + ('bar' if is_bar?))
Though I feel it to be a blemish if is_bar? return false and the generated HTML results in
<div class="foo "></div>
(the blemish is the blank character after the foo). If someone had a solution for that would be awesome.

Getting the reviews page URL for a product in the product page sidebar [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I am trying to get the url for a products reviews page in the sidebar on that products page. I know this can't be that difficult, but it is defeating me at the moment..
I can get the product page URL (basically the url for the page the sidebar is on) but not the reviews page... which is essentially the same url with -reviews.htm at the end instead of just .htm
Where am I going wrong? What call do I have to make?
In your (your theme) catalog.xml file find the section beginning with <catalog_product_view translate="label">
Look for <reference name="right">.
If your template does not have a right section in product view, add one in below content and enter:
<reference name="right">
<block type="review/product_view_list" name="product.info.product_additional_data" as="reviews" template="review/product/view/list.phtml"/>
</reference>
Make sure you have cache off, load your product page (hopefully a product with a review on there) and you should now have the necessary.
You'll also be wanting to have the 'add a review' box on the product page to make it easier for people to add a review. There are some really clumsy ways to do this that don't work properly. However, this is the easy, simple way...
Open the same layout.xml file you had earlier, go to the catalog_product_view section, go right to the bottom of the content section. Look for the final closing </reference> tag. Now add:
<block type="review/form" name="product.review.form" as="review_form" template="review/form.phtml"/>
Now go to the front end, add your testimonial and note how wonderfully it all works, complete with theme etc.
Hopefully, with this example you will begin to understand how powerful and useful the Magento layout xml files are.
Extra
Since it is a new block that is needed, you need new template file.
Add:
app/design/frontend/base/default/template/review/sidebar.phtml
Enter into it something like:
<div class="block block-reviews">
<div class="block-title">
<strong><span>Reviews</span></strong>
</div>
<div class="block-content">
<p>MacGuffin!</p>
</div>
</div>
Edit app/code/core/Mage/Review/Block/Product/View/List.php and add the helper URL function before the class closing brace:
public function getMacGuffin($id)
{ return Mage::getUrl('review/product/list', array('id'=> $id));
}
Now sort out your layout XML add to the reference left block or reference right, whatever, for the product page directives:
<block type="review/product_view_list" name="review_sidebar" as="macguffin" template="review/sidebar.phtml"/>
That gets you the link you wanted, in a nice sidebar block with some stuff you can CSS to. Copy it over to your main theme.
You can take what you want from the list.phtml template I pointed you towards earlier and do your own code to summarize your reviews or say something else if you have no reviews.
Does <?php echo $this->getReviewsUrl() ?> work for you?
Otherwise you can always get the product URL like you said, explode it on the ".", insert reviews and stick them back together. I don't think that's a fail-safe solution though, as the review URL's on my Magento installation look very different from the product page URLs, so you might break something during an upgrade. (e.g, my product page looks like domain.com/category/product.htm, but the review page is: domain.com/review/product/list/id/10450/category/281/#review-form)
Edit:
I dug a little deeper. I found the $this->getReviewsUrl() in a helper template at app/design/frontend/base/default/template/review/helper/summary.phtml.
That explains why you cannot use the method on the product page itself; it has a different context. The Block helper for this template at app/code/core/Mage/Review/Block/Helper.php has the answer though:
public function getReviewsUrl()
{
return Mage::getUrl('review/product/list', array(
'id' => $this->getProduct()->getId(),
'category' => $this->getProduct()->getCategoryId()
));
}
You can use this function's content in your template to generate the link you want.

Resources