小编Joh*_*per的帖子

backbone.js和el属性

(function ($) {
window.AppView = Backbone.View.extend({
  el: $("body"),
  events: {
    "click #add-friend":  "showPrompt",
  },
  showPrompt: function () {
    var friend_name = prompt("Who is your friend?");
  }
});
var appview = new AppView;
})(jQuery);
Run Code Online (Sandbox Code Playgroud)
  1. 任何人都可以解释一下el这里有什么.它是元素吗?
  2. el参数是否接受对象,如果是这样,我可以传递我的自定义视图对象,其中我的按钮或元素需要添加...

javascript backbone.js

7
推荐指数
1
解决办法
4689
查看次数

为什么一个类实现了Serializable接口?

@Entity
public class Husband implements Serializable {

   @Id
   private int id;

   private String name;

   @OneToOne
   private Wife wife;

}

@Entity
public class Wife implements Serializable {

   @Id
   private int id;

   private String name;

   @OneToOne(mappedBy="wife")
   private Husband husband;

}
Run Code Online (Sandbox Code Playgroud)
  1. 什么是Serializable广义的?
  2. 为什么类实现Serializable接口?
  3. 为什么单独的丈夫成员有@OnetoOne(mappedBy ="妻子"),但妻子成员没有@OnetoOne(mappedBy ="丈夫")

java jpa

6
推荐指数
2
解决办法
2万
查看次数

什么时候在java中使用flush()?

import java.io. * ;
public class Ser {

    public static void main(String args[]) {

        try {
            John myObj = new John("Sachin", "Cricket");
            System.out.println(myObj);
            FileOutputStream fos = new FileOutputStream("FileName");
            ObjectOutputStream oos = new ObjectOutputStream(fos);
            oos.writeObject(myObj);
            oos.flush();
            oos.close();
        } catch (Exception e) {
            System.out.println("Expection" + e);
            System.exit(0);
        }

        try {
            John myObj2;
            FileInputStream fis = new FileInputStream("FileName");
            ObjectInputStream ois = new ObjectInputStream(fis);
            myObj2 = (John) ois.readObject();
            ois.close();
            System.out.println("New Object" + myObj2);
        } catch (Exception e) {
            System.out.println("Expection" + e);
            System.exit(0);
        }

    } …
Run Code Online (Sandbox Code Playgroud)

java serialization

6
推荐指数
2
解决办法
4万
查看次数

复杂的JSON和教程

任何人都可以向我展示一些复杂的JSON结构和教程,我可以使用它来更好地使用这个JSON主题javascript.到目前为止,我能够理解JSON,它的基本结构以及如何解析和警告属性.

我可以搜索谷歌或其他搜索引擎,但我想要你的专家的链接谁可以引导我正确的方向而不是显示结果的BOT.

javascript json

5
推荐指数
2
解决办法
9401
查看次数

计算几个月和几天的年龄

function getAge(dateString) {
    var today = new Date();
    var birthDate = new Date(dateString);
    var age = today.getFullYear() - birthDate.getFullYear();
    var m = today.getMonth() - birthDate.getMonth();
    if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) {
        age--;
    }
    document.write(age);

}

getAge("01/20/2011")
Run Code Online (Sandbox Code Playgroud)

这显示我0年,但我想显示10 Months和9个月,直到他的生日来临10/20/2011.

javascript

5
推荐指数
1
解决办法
9403
查看次数

从字符串中删除HTML(在JSON响应中)

var json = {
    "Item": {
        "Items": {
         "Body": "<SPAN style=\"LINE-HEIGHT: 115%; FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 11pt; mso-fareast-font-family: Calibri; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA\">\"We have all been inoculated with Christianity, and are never likely to take it seriously now! You put some of the virus of some dreadful illness into a man's arm, and there is a little itchiness, some scratchiness, a slight discomfort, disagreeable, no doubt, but not the fever of the real disease, the turning and the tossing, …
Run Code Online (Sandbox Code Playgroud)

javascript

5
推荐指数
1
解决办法
2万
查看次数

JSON和Array之间有什么区别?

JSON和Array之间有什么区别?他们为什么调用JSON对象和数组对象.

http://wiki.appcelerator.org/display/guides/Using+TableViews+-+data.js

这是一个数组还是JSON?我怎么识别?

javascript

4
推荐指数
1
解决办法
6810
查看次数

如果/ else条件在Object内

function Validator(formIsValid) {
    if(this.formIsValid) {
        alert('Form is valid!');
    }
    else {
        alert('Form is invalid...');
    } 
}
Validator.prototype = { // Notice the .prototype here, it's important!

  formIsValid: true, 

  enforceTextFieldMinLength: function(field, minLength) {
      if (!field.value || field.value.length < minLength) {
            this.formIsValid = false;
      }   
  },

  enforceLabelHasText: function(label) {
        if (!label.text) {
            this.formIsValid = false;
        }
  }
}
//var val = new Validator();
Run Code Online (Sandbox Code Playgroud)

以上是我的Val.js. 这就是我在otherFile.js中使用的方式

AddPatient.Firstname = FirstNameValue || Validator.enforceLabelHasText(FirstName);  
Run Code Online (Sandbox Code Playgroud)

我收到一个错误说 cannot find function enforceLabelHasText in Object function Validator(formIsValid)

javascript

4
推荐指数
2
解决办法
1万
查看次数

函数内部的return语句有什么用?

    var obj = {

        func: function() {    
        return: {
           add: function() {
             }
          } 
        },
        somefunc: function() {
      }
   } 
Run Code Online (Sandbox Code Playgroud)

我用来转换这个的原始代码...

var hash = (function() {
     var keys = {};
     return {         
     contains: function(key) {
     return keys[key] === true;         
     },
     add: function(key) { 
     if (keys[key] !== true){
         keys[key] = true;             
     }     
  }; 
})();
Run Code Online (Sandbox Code Playgroud)

问题:

  1. return关键字有什么用?
  2. 我的课程可以像这样构建吗?

javascript

4
推荐指数
1
解决办法
4512
查看次数

在两个数字之间生成随机数

public class TestSample {
    public static void main(String[] args) { 

        int a = Integer.parseInt(args[0]);
        int b = Integer.parseInt(args[1]);

        double ran = Math.random();



    }
}
Run Code Online (Sandbox Code Playgroud)

我不想Random r = new Random();上课.有没有其他方法来生成随机数.我很惊讶可以应用什么逻辑来生成两个数字之间的随机数.

java random algorithm

4
推荐指数
2
解决办法
8213
查看次数

标签 统计

javascript ×7

java ×3

algorithm ×1

backbone.js ×1

jpa ×1

json ×1

random ×1

serialization ×1