Some of the recent studies, as well as some of the problems encountered in the summary

Source: Internet
Author: User

1. First I used a layer of the entire page as a mask layer of a technology, reference link: ttp://layer.layui.com/

2. There are some problems with the operation of the page, I want to store the data in the array and execute the operation together. So I met some problems. Summarized as follows:

  

JS question:
1.prototype, for some encapsulated class or property or function registration method, using the following example:
Array.prototype.remove = function (obj) {
for (var i = 0; i < this.length; i++) {
var temp = this[i];
if (!isnan (obj)) {
temp = i;
}
if (temp = = obj) {
for (var j = i; J < This.length; J + +) {
THIS[J] = this[j + 1];
}
This.length = this.length-1;
}
}
}
The method above is to register a remove method with the array.
2. Pop the view page as a mask layer using the following method:
Eject IFRAME Layer Reference http://layer.layui.com/
function Mappingiframe (placeid,ids) {
IFRAME Layer
Layer.open ({
Type:2,
Title: ' Mapping ',
Shadeclose:true,
shade:0.8,
Area: [' 1100px ', ' 600px '],
Content: URL of '/tr/journeyplan/mapping?ids= ' + ids + ' &&placeid= ' + placeid+ ' &&y= ' +math.random//iframe
});
}


Sub-page code:
var index = Parent.layer.getFrameIndex (window.name); Get window Index
function Save () {
var returnvalue = "";
var Arrchk = $ ("input[name= ' ckxlist ']:checked");
if (Arrchk.length > 0) {
$ (ARRCHK). each (function () {
ReturnValue + = This.value + ",";
});
}

if (top.window.saveMapping) {
Top.window.saveMapping (' @ViewBag. Placeid ', returnvalue);
}
parent.$ (' #parentIframe '). Val (returnvalue);//Pass value to Parent page
Parent.layer.close (index);//Close IFRAME
}


3. Methods for passing values between pages: (callback function) The sample code is as follows:
On the Sub-page write:
var index = Parent.layer.getFrameIndex (window.name); Get window Index
function Save () {
var returnvalue = "";
var Arrchk = $ ("input[name= ' ckxlist ']:checked");
if (Arrchk.length > 0) {
$ (ARRCHK). each (function () {
ReturnValue + = This.value + ",";
});
}

if (top.window.saveMapping) {
Top.window.saveMapping (' @ViewBag. Placeid ', returnvalue);
}
parent.$ (' #parentIframe '). Val (returnvalue);//Pass value to Parent page
Parent.layer.close (index);//Close IFRAME
}
4. How to turn the page to JSON

(1). Jquer package Good This method: Serializearray ()
var a=[];a.serializearray ();
(2). Text = Json.stringify ([' E ', {pluribus: ' Unum '}]);
Json.stringify, the function is mainly for the serialization of objects. (or convert the original object to a string, such as a JSON object):
First define a JSON object, var jsonobject = {"UserID": "1", "UserName": "Xiaozhang"};
var jsontext = json.stringify (jsonobject); alert (jsontext);
(3) Jquery.parsejson, converts a JSON string to a JSON object (Json.parse also parses a JSON string into a JSON object), as in the following
First define a JSON string, var c = ' {' name ': ' Mike ', ' sex ': ' Male ', ' age ': ' 29 '} '; (note: single quotes are written in {}, each property name must be in double quotation marks, otherwise an exception will be thrown.) )
var Employeejson=jquery.parsejson (c);

The parent page requires a savemapping method.
MVC: the problem.
1. Get the name of the controller and the name of the view inside the view:
Var?controllername?=?
viewcontext.routedata.values["Controller"]==null? ": viewcontext.routedata.values[" Controller ". ToString ();
Var?controllername?=?
viewcontext.routedata.values["View"]==null? ": viewcontext.routedata.values[" View ". ToString ();
2. Filter the validated classes and how to get the controller and view methods:
String url = httpContext.Request.Url.ToString ();
var rolestemp = URL. Split ('/');
String limit = Rolestemp[3]. ToString () + rolestemp[4]. ToString ();
if (list. Contains (limit))
{
return true;
}

Some of the recent studies, as well as some of the problems encountered in the summary

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.