Save & Apply mechanism of Luci

Source: Internet
Author: User
Tags reset

When creating the Luci interface with the Luci framework, the page defaults to controls such as "Save & Apply", "save", "reset", "help", and, of course, the help control will determine if the developer has set the corresponding help page to decide whether to display the control. Because of the controls created by the framework, it is necessary to understand the framework to get control state.

Application 1: In the configuration interface to determine whether the "Save & Apply" "Save" control is pressed, get the message that the control presses, and then do the appropriate processing. In fact, the response mechanism of these several controls is done in/luci/view/cbi/footer.tm:

<%-if Pageaction then-%>
<div class= "Cbi-page-actions" >
<% if redirect then%>
<div style= "Float:left" >
<input class= "Cbi-button cbi-button-link" type= "button" value= "<%:back to Overview%>" onclick= "location.href = ' <%=pcdata (redirect)%> ' "/>
</div>
<% End%>


<% if Flow.skip then%>
<input class= "Cbi-button cbi-button-skip" type= "Submit" Name= "Cbi.skip" value= "<%:Skip%>"/>
<% End%>
<% if not autoapply then%>
<input class= "Cbi-button cbi-button-apply" type= "Submit" Name= "cbi.apply" value= "<%:save & Apply%>" onclick= "Window.parent.scrollTo (0,0)"/>
<% End%>
<input class= "Cbi-button cbi-button-save" type= "Submit" Name= "Cbi.save" value= "<%:Save%>" onclick= " Window.parent.scrollTo (0,0) "/>
<input class= "Cbi-button cbi-button-reset" type= "reset" value= "<%:Reset%>" onclick= "Window.parent.scrollTo (0,0) "/>
<% if Help_url then%>
<input class= "Cbi-button cbi-button-help" type= "button" value= "<%:Help%>" onclick= "location.href=" <%= Luci.dispatcher.build_url (Help_url)%> ' "/>
<% End%>
<script type= "Text/javascript" >cbi_d_update ();</script>
</div>
<%-End-%>
</form>
<%+footer%>

From the code, this is defined in the HTM file, the control name of the page, the name of the message, the action corresponding, and so on, such as the definition of "Save & Apply":

<input class= "Cbi-button cbi-button-apply" type= "Submit" Name= "cbi.apply" value= "<%:save & Apply%>" onclick= "Window.parent.scrollTo (0,0)"/>

Cbi.apply is the name of the broadcast message, so developers can use the CBI to create a configuration interface under mode:

Local apply = Luci.http.formvalue ("cbi.apply")
If Apply Then
Luci.sys.exec ("UCI commit Network")
End

To intercept the message and do the appropriate processing,

The "Save" control is the same, the same way, but the apply mechanism in the luci/view/cbi/apply_xhr.htm to do another xhr mechanism, is to click on "Save & Apply" The process is then displayed in the header: for example, which file is being configured, and so on.


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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.