javascript - jQuery Stop hide div on submit -


I have a simple show / hide div and a form on the div, but when i submit the form then div again Reload to hide, how do I stop this behavior?

script:

  $ (function () {$ ('.mbox'). Hide (). (Function (e) {eStopprogation ();} ); $ ("#mbbiton") (function (e) {$ ('.mbox'). Animate ({obscure: "toggle"}); e.preventDefault ();});});   

div:

  & lt; Li & gt; & Lt; Div class = "mbox" & gt; Input  & Lt;% = text_area: Message,: body, class = & gt; "Span5",: rows = & gt; 5 ,: Placeholder = & gt; "Mensenjam"% & gt; & Lt;% = f.button "Send" ,: class => "Boutao"% & gt; & Lt; / Div & gt; & Lt; / Li & gt;  

It seems that when the page is initially full, the div is hidden, Then you click on the form submission to fill the form and fill the form, the page reloads, and when you want it still shown, hidden from it, it reloads again .

(assuming that initially the hidden device is controlled in CSS because I do not see it anywhere else in the code provided)

If this is the case, So I think you have two options.

  1. To handle this on the server side, to fill out the form, Are changing

  2. If possible, on the customer side, handle it, say, Faw Filling the filling reveals the values ​​that are reloaded, but if the page does not get value in the beginning, then you can write some JS to show the div when the value is in the form.

    I will also see a complete reload on the page, even if you come back with the same data in the same data and only want to see it the same. Maybe you should submit via AJAX and should not load the page at all?

Comments