I'm using Elixir 1.7.2 + Phoenix 1.3 and I've a delete link that has a data prompt of "Are you sure?" before confirming the deletion.
The problem is, when you click the delete button in the application it asks for multiple consecutive "Are you sure?" confirmations (sometimes as many as 6) before it actually allows you to delete.
The code for the delete link is:
<%= link to: project_document_path(conn, :delete, project, document),
method: :delete,
data: [confirm: "Are you sure?"] do %>
<img class="absolute k-w2-5 top-0 left-1" src="/images/delete.svg" />
<% end %>
Has anyone else experienced this behaviour in Phoenix with links that have confirmation prompts and knows how to solve it?
Thanks in advance!
This was happening because we were requiring our javascript file in multiple locations, one for each time we were calling a javascript function. We now have one instance of our require in our app.html.eex file which covers our whole view file tree. This is the code that was replicated:
<script src="<%= static_path(#conn, "/js/app.js") %>"></script>
Related
Situation:
I am a HTML newbie who gets by through Google-fu and I am in charge of a tool which sends HTML email to customers.
I have been asked by our customers (Because pressing reply and typing a single word is really difficult) if I can create buttons on the emails I send which allows them a 1-click reply.
Conditions:
The reply has to come from their own email address
It needs to go back to the email address that sent the email (We have one template email which can be sent from several addresses)
It needs to maintain the same subject line (It contains a reference number to ensure the email is processed correctly when received)
Must be created using inline HTML(4 or 5) only (Restrictions of the system that generates the email)
Ideally will send the reply immediately (And show them as much in some manner), but opening up a new email already pre-populated is an acceptable alternative
I have struggled to find much at all on this, which leads me to think that it is not possible.
If using tiny bit of pure javascript, that does not need any external library on your website.
This code goes to your website where you want your check to be made.
<script>
function getURLParameter(name) {
return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search) || [null, ''])[1].replace(/\+/g, '%20')) || null;
}
document.addEventListener("DOMContentLoaded", function(event) {
if(getURLParameter('answ') == 0) document.getElementById('answered_yes').remove();
else if(getURLParameter('answ') == 1) document.getElementById('answered_no').remove();
else {
document.getElementById('answered_yes').remove(); document.getElementById('answered_no').remove();
}
});
</script>
<div id="answered_yes">
THIS IS HOLDER FOR YES ANSWERER //Put your wanted info hare if he answered yes
</div>
<div id="answered_no">
THIS IS HOLDER FOR NO ANSWERER //Put your wanted info hare if he answered no
</div>
Now on email links put these type of links.
<a href="yourwebsite.com/index.php?answ=0" target="_blank" >ANSWER NO</a>
<a href="yourwebsite.com/index.php?answ=1" target="_blank" >ANSWER YES</a>
What this does is simply puts a parameter on a link called answ that has 0 or 1 by my setting and once your website gets a request it checks which parameter is it 0 or 1. If its 0 that means we remove the div that says yes, otherwise do the same with no div.
with only html it is not possible unless you would give him different links as in.
<a href="yoursite.com/he_answered_no.html" >No</a>
<a href="yoursite.com/he_answered_yes.html" >Yes</a>
And put your contents inside there.
However if you are going to use this script in your website, put that code somewhere in the body, its not perfect, but it will do the job. Then put your information on yes div and on no div, its going to remove whatever div he answers too.
But like I mentioned, with purely HTML it is not possible only adding some bits with other languages, pure javascript should work on any HTML site, unless you are trying to add the code to some kind of platform that blocks any ongoing scripts.
You can just use a "mailto:" link similar to this:
Email Us
Here's the link with more info: https://css-tricks.com/snippets/html/mailto-links/
It will open up a prepopulated email with the "to" address, subject line, and body text already inserted. People will be able to modify the text if they want or just click send. You would need to some way to dynamically change the subject line to the one the customer received, but your email tool probably has that capability.
Recently i am started tuning our products to IE compatability. Now i am facing a weird problem in IE alone.
My form url is something like this https://x.com/formurl/dynamicvalue
and my form element is
<form action="" method='post'>
...
</form>
some values the dynamicvalue holds are ( Alphanumeric characters )
plan
plan2
1234443
544
Except IE every other browsers sending the actions to https://x.com/formurl/dynamicvalue
IE form action is sending to https://x.com/formurl
I don't know why this is happening, I can replace the document.URL to post the Form back to solve the problem. Still, i want to what's the reason for IE to remove that dynamicvalue
I am testing in IE-9
Kindly someone teach me.
Thanks in advance.
I have also discovered this bug in Internet Explorer 11 when reading the action attribute of a form with action set to the empty string.
<form action="" method="post"></form>
If one reads the form.action attribute in javascript and the current URL does not contain a trailing slash, the last part of the URL will be removed. I.e., if the location is example.com/xxx/yyy, form.action=="example.com/xxx, while if location is example.com/xxx/yyy/, form.action=="example.com/xxx/yyy/.
However, if the form is posted by clicking a submit button, it is posted to the correct URL, i.e., example.com/xxx/yyy or example.com/xxx/yyy/.
I overcame this by using jQuery's attr function to check if action="" in the HTML and then I use location.href instead.
if($(form).attr('action') === '') return location.href else return $(form).attr('action')
(Why would someone do this? I am intercepting the form submit and using ajax to send the data. To do this, I need to know where the form wants to submit)
I`m trying to add link to order review in order confirmation email:
<a href="{{store url="sales/order/view/order_id/}}"{{var order.id}}" style="color:#1E7EC8;">
But when customer get the email it links just to http://mysite/sales/order/view/
Hi,
<a href="{{store url="sales/order/view/order_id/"}}{{var order.id}}" style="color:#1E7EC8;">
This is okay but it still not shows full link. It shows only sales/order/view/.
To show **order_id/**, you have to create Custom Variable.
Go to **System >> Custom Variables**.
Check Image below.
**http://imagizer.imageshack.com/img922/1470/tI8BGv.png**
Now create custom variable shown in image with any name.
Now revise the code and change the line.
<a href="{{store url="sales/order/view/"}}{{customVar code=static_url}}{{var order.id}}" style="color:#1E7EC8;">
It's working fine for me.
Thanks & Regards.
Move your quotes.
<a href="{{store url="sales/order/view/order_id/"}}{{var order.id}}" style="color:#1E7EC8;">
I would like to provide a link when clicked it will send an email to an admin to inform them to delete a record. I have searched for several hours, included here but could not find any examples.
Here is the current code I would like to modify:
link_to "Delete your User Account?", #user, method: :delete, confirm: "You sure? This will permanently delete your account. If you want to access our site in the future you will need to create a new account again. Are you sure you want to delete your account?" %>
I would like to substitute "method: :delete" with an ActionMailer method. I looked in the Ruby documentation at api.rubyonrails.org and other places for examples but could not find anything.
Is this something I can do without installing a gem?
Why is it so hard to find documentation with examples? Sigh.....
The "method: delete" is the HTTP methods passed in the headers when you call the url which is then used by the routes to find the correct controller and action.
You will want to place your method calls to the mailer in your controller where User#destroy action is.
it would be something like this.
def destroy
#user = User.find(params[:user])
if #user.desotry
# Tell the UserMailer to send a email after destroy
UserMailer.delete_account_email(#user).deliver
redirect_to(#user, :notice => 'Account was successfully closed.')
end
end
I am trying to figure out how to perform some inter dashlet communication with Alfresco Share.
Here a simple use case:
We do have 2 dashlets, let's call them A and B. I want to be able to fill in a field "name" (let's say with value "Toto") in A and click on submit button. After clicking on submit button in A. B should be updated with greeting like " Good Morning Toto".
Thank you for you answers.
Thanks for your answer. Can you elaborate a bit regarding "let dashlet_b.get.html.ftl post something to dashlet_a.post.html.ftl" ?
In dashlet_b.get.html.ftl you have something like that I guess :
<form id="..." action="" method="POST">
<input id="name" type="text" name="name" value=""/>
<input type="submit" id="send" value="Send" /></form>
When you submit the form it's gonna look for dashlet_b.post.js right ? How do you actually tell to send the form to dashlet_a.post.js ?
To create these dynamic dashlets it is not enough to use the server side dashlet webscript. You need javascript logic in the browser to notify the other dashlet of changes. This is how Alfresco usually does that:
Browser Javascript Dashlet A:
YAHOO.Bubbling.fire("interDashletMessage",
{
message: "Hello World."
});
Browser Javascript Dashlet B:
YAHOO.Bubbling.on("interDashletMessage", function(layer, args) {
var message = args[1].message;
alert(message); // or write it to the dashlets HTML content
});
This will send the message from dashlet A to dashlet B using a custom event called "interDashletMessage".
If your dashlet B only displays a few messages it could be enough to send the data over using the events. If it is more complex your dashlet A needs to post it's data to the repository first, then trigger the "refresh" event and have dashlet B refresh it's content from the repository. This will involve multiple webscripts you may need to write.
That's quite simple I guess.
Each Dashlet is in fact a webscript. So you can have multiple webscript for different usage. Like I've got dashlet_a.get.html.ftl and dashlet_a.post.html.ftl.
In fact these two are the same webscript, one just acts on a post and the other on get.
So what you could do, is let dashlet_b.get.html.ftl post something to dashlet_a.post.html.ftl. Hence you are submitting value(s) from b to a.
The next step is to refresh dashlet_a, one way is to do a full page refresh, but that's not nice.
Whats better is the following:
In dashlet_a.post.html.ftl you just set through YUI/JQuery the value of the field which is defined in dashlet_a.get.html.ftl.
Take a look how the default configurable dashlet do it, like the webview. If you put something in the config, the value directly is shown.