[Oldboy-django] [1 Django] Block default event occurrence + Ajax + modal Edit dialog box

Source: Internet
Author: User

4prevent default events from occurring a block a label default event occurrence method<a href="http://www.baidu.com"onclick="Modaledit ();"> Click </a>Click on the a tag above there will be two events: Modaledit and jump to Baidu home, priority high Modaledit () if you want to prevent the jump to Baidu home event occurred, need to change to the following:1add return in tag<a href="http://www.baidu.com"onclick="return Modaledit ();"> Click </a>2Event Modaledit Add return False function Modaledit () {....return false; } b prevents the submit default event occurrence method in form form5ajax+dialog box (single-table Class) Click Edit to Process step, edit button bind event A. Get all the information for the current editing class--Front End-Find Father Parent (), find the father's front two tags prevall () b. Pop-up dialog box and display the default information--Front End-Removeclass ("Hide")            -val (id) #id的input输入框隐藏-Val (title) c. Click the Submit button to send the data to the background--Ajax-$.ajax ({URL:'/modal_edit_class/', type:'POST', data: {'nid': Nid,'title': Title}, Success:function () {}}) D. Background exception handling (insert database), processing dictionary JSON as a string, returning HttpResponse ()--Server-ret = {'Status': True,'msg': None}-Try{Update database operation}-returnHttpResponse (json.loads (ret)) E. Front-end receive strings, anti-JSON processing, judging and doing different operations--Ajax-success:function () {}--success, refresh current page location.reload ()--failed, display failure message-deserialization--Json.parse (string)            -serialization of the front end--Json.stringify (dictionary)

[Oldboy-django] [1 Django] Block default event occurrence + Ajax + modal Edit dialog box

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.