I am developing a user profile page, which has two modes - view and edit. The page starts in the view mode when it first loads. To enter the edit开发者_开发问答 mode, user needs to click on the "edit" button and then the page becomes a form.
I am thinking to include, in the html, the markup for both the view mode and the edit mode (in div) and hide the edit div to begin with. Once user clicks on the "edit" button, use JQuery to hide the view div and show the edit div.
Is this approach reasonable? Would it lead to any undesirable side-effects? Feel free to suggest any better approaches, if any.
By the way, for the server-side I am using Django
seems like a reasonable approach. Just make sure you do the appropriate server side validation of the data submitted by the user. Remember if its hidden with javascript, the user can still post the data back and bypass any client side validation.
Having said that, if the edit button is only visible to a set of authorised users, you may want to hide the edit button in the server side.
精彩评论