My page display a list of question. Near each question, a button switch a hidden statement to display a model over the page asking for some information. The goal would be, after the user complete the information and click submit, to access the backend and send the information to the database WITHOUT loading another page. I would like this popup to close and the user to resume what he was doing as if he did not do anything.
How would I go about doing something like this ?
You can use ajax and send a Post HttpRequest to an action which would then be tasked to save those information.
Please refer to this thread and this for more info.
Hope this helps you.
Related
Is there a way to do any of the following:
a. Update a chat message that initiated a dialog.
b. Store "hidden" fields in a dialog.
Basically, I have a bot message that opens from a button on a message attachment. I know when the user clicks the button, I get the ts of the message and at that time I could alter it. However, the workflow is not complete until the user has submitted the dialog, but the submit on the dialog loses all the original_message stuff and the ts of the dialog being submitted no longer corresponds with the original, calling message.
If there was a mechanism to store hiddens, I could stash the original ts or the response url on the form itself.
Thanks! This is my first slack workflow, so any advise is appreciated as usual!
.....
The suggested duplicate answer refers to an interactive message, which I'm using to call the dialog already.
However, that isn't where my problem is, it is the dialog submission.
You don't have any access to the button elements on a dialog and the dialog element can only have 5 elements of type: text, select, text area. Plus it's a bit overkill considering that a action invocation from an interactive message actually includes the original message in the post back to your server.
So slack dev support got back to me:
Thanks for writing in, this is a great question!
You can use the callback_id parameter when calling dialog.open to store a string that will help your app locate the message. This callback_id will be returned to you in the dialog submission.
In your case, you could store the original message's ts and channel_id so that > you can locate the message to update.
I hope this helps! Let me know if you have any further questions!
So, it's a bit hacky (imo), but i did get it to work so I thought I'd close this question in case anyone else ran into this.
I'm just parsing the original ts value inside the callback w/ some other data i can use when the form submits. The only limitation to this is that it only stores 200 characters but that should be sufficient considering that is in addition to the 5 fields you have on the dialog and the other stuff slack gives you in the post (user, channel, etc).
For usability reasons, I have the requirement that an error page should tell the user something on the lines of
Sorry, we could not find this product in our database. You can go back to the previous page or search for a different product.
where the go back link is supposed to provide the same functionality as the back button.
I tried implementing it using Request.UrlReferrer, but it was a null in the smoke test. I found an answer here on SO which says that the browser can be set to not send it and
Bottom line is that you shouldn't trust it. Just append the url to the GET string and redirect based off that.
But as this view is displayed by using the default exception handling filter of MVC, I cannot append this in my code, as it does not send the user to the view in the first place.
Do I have to write my own exception handling filter if I want this functionallity, or is there a simpler way to do it? If I have to write it, what are pitfalls to look out for? It is possible that we will drop the link requirement if this means a substantial increase in the complexity of our code and just let the users click their own back button, but I don't have the experience to make an estimation.
I recommend solving this with JavaScript. Try
window.history.back()
As the onclick event for your anchor tag.
I was wondering which way would be the best for my following problem. and maybe sample on how to do it also
I have the following models: customer, music, books.
What I would like to do is when a customer wants to go into the edit page then automatically customer general information such as name, password show up! But on an other tab by pressing music which his another model then music information comes up in the same. Sorta like facebook and twitter edit page do it.
Now each of the form are rendered by the following code line at the moment
<%= render 'general'%>
but how do i include them in the link and should i just use javascript and toggle them or use ajax ??
Thanks
Well, this has little to do with Ajax, since all information you need aparently would already been loaded by you main customer object.
What i understand you want is something like the tabs javascript plugin of twitter bootstrap: http://twitter.github.com/bootstrap/javascript.html#tabs
You put the different content (music/books/etc) in different divs and when the tab is clicked, the content changes and the user gets a better experience.
Take a look at the link, it is super easy to set up this plugin on your project.
I have a website which is basically a single page containing a bunch of dynamic content. In normal operation the user should never leave this page. To handle/report certain errors though, I need to redirect to an error page. So on the error page I want to provide a link back to the normal page which provides the app the information required to rebuild all the dynamic content which was previously open.
I think I can rebuild the page by parsing the querystring with javascript and reloading dynamic content. I'm not sure if this is the best way, but I've got it working. So href in the link on my error page needs to look something like:
MySite/MyController/MyAction?1,5,8,9
where the numbers in the querystring basically indicate the Id's of content sections to load in on document.ready.
I'm now stuck on how to generate this link though. I think I need to pass these numbers into the controller somehow, so the controller can pass them into the error view which will then generate the "back" link.
I have a standard html form for uploading a file:
using (Html.BeginForm("MyAction", "MyController",
FormMethod.Post,
new { enctype = "multipart/form-data" }))
{ /* ... */ }
I then have a button which calls the jQuery .submit() method on the form.
So, the question, when I click on the button which submits the form, how can I attach the additional data so I can access it in my controller?
Hope that's clear, if not let me know and I can provide more detail. Thanks.
Edit: It occured to me that I could submit this information with a hidden field in the form. I'll try that if I can't find a better way, but I'd like a more generic solution if possible as I have a number of forms on the page and ideally I'd like this data available to any/all of them.
your url should be biult just before sending the form with .submit() not in Html.BeginForm tag....
i can't see the problem over here... what exactly you are dealing with?
I know this is not quite what you asked but instead of going through the hassle of redirecting the user in the first place why don't you show a modal window (a jquery based one) that contains an iFrame. The iFrame href can be determined by the calling page and can show the error page.
Not sure if this helps but I have used this technique and found that I do not need to worry about getting the user back to the place where they started from. Additional to this you will not need to rebuilding/reloading the orignal content as it will still be on the calling page.
****EDIT**** After reading your comments maybe you could do the following...
On the link click - open up a modal popup pointing to an iframe.
The iframe calls the action on the controller to download the file.
The view could say "Downloading file... please wait, click here to close etc."
If the action throws the error then redirect to the error page as normal as it is within the iframe modal popup.
This way you do not need to leave the current calling page.
I am using the method from this question to create a pop-up to show a form where the user must "sign" it and then click submit. I have the pop-up working and displaying data. Now I want to submit the form to a POST action and close the pop-up if the POST was successful.
I have been scouring the internet looking for something close to what I think I am looking for, but seeing anything. Can someone offer me some direction?
You can either do it manually via http://api.jquery.com/jQuery.post/ (it has on success callback) or use jQuery ajax form plugin http://jquery.malsup.com/form