2
2
OwnershipsCount = $ ( "#Tags>input" ) . length ;
3
3
AuthorFieldsCount = $ ( "#Authors>input" ) . length ;
4
4
GenresFieldsCount = $ ( "#Genres>input" ) . length ;
5
- $ ( ".remove-field" ) . click ( RemoveField ) ;
5
+ $ ( ".remove-field" ) . click ( removeField ) ;
6
6
7
7
$ ( ".bookCover" ) . click ( function ( ) {
8
8
var link = $ ( this ) . child ( ) . attr ( src ) ;
@@ -13,13 +13,13 @@ var OwnershipsCount = 0;
13
13
var AuthorFieldsCount = 0 ;
14
14
var GenresFieldsCount = 0 ;
15
15
16
- function AddField ( type ) {
16
+ function addField ( type ) {
17
17
//добавляем поля
18
18
if ( type == "Tag" ) {
19
19
var OwnershipContainer = $ ( "<div/>" ) . attr ( "class" , "ownership-container" ) . attr ( "id" , "OwnershipContainer" + OwnershipsCount ) . appendTo ( $ ( "#Tags" ) ) ;
20
20
$ ( "<input/>" ) . attr ( "class" , "text-box single-line" ) . attr ( "type" , "text" ) . attr ( "id" , "Ownerships[" + OwnershipsCount + "]_Name" ) . attr ( "name" , "Tages[" + OwnershipsCount + "].Tag_Name" ) . attr ( "value" , "" ) . appendTo ( OwnershipContainer ) ;
21
21
var RemoveButton = $ ( "<a/>" ) . attr ( "class" , "remove-field glyphicon glyphicon-remove" ) . attr ( "item" , OwnershipsCount ) . attr ( "href" , "#" ) . appendTo ( OwnershipContainer ) ;
22
- RemoveButton . click ( function ( ) { RemoveField ( type , RemoveButton ) ; } ) ;
22
+ RemoveButton . click ( function ( ) { removeField ( type , RemoveButton ) ; } ) ;
23
23
OwnershipsCount ++ ;
24
24
}
25
25
else if ( type == "Author" ) {
@@ -28,21 +28,20 @@ function AddField(type) {
28
28
$ ( "<input/>" ) . attr ( "class" , "text-box single-line" ) . attr ( "type" , "text" ) . attr ( "id" , "Author" + AuthorFieldsCount + "Middle" ) . attr ( "name" , "BookAuthors[" + AuthorFieldsCount + "].Middle_Name" ) . attr ( "value" , "" ) . appendTo ( OwnershipContainer ) ;
29
29
$ ( "<input/>" ) . attr ( "class" , "text-box single-line" ) . attr ( "type" , "text" ) . attr ( "id" , "Author" + AuthorFieldsCount + "Last" ) . attr ( "name" , "BookAuthors[" + AuthorFieldsCount + "].Last_Name" ) . attr ( "value" , "" ) . appendTo ( OwnershipContainer ) ;
30
30
var RemoveButton = $ ( "<a/>" ) . attr ( "class" , "remove-field glyphicon glyphicon-remove" ) . attr ( "item" , AuthorFieldsCount ) . attr ( "href" , "#" ) . appendTo ( OwnershipContainer ) ;
31
- RemoveButton . click ( function ( ) { RemoveField ( type , RemoveButton ) ; } ) ;
31
+ RemoveButton . click ( function ( ) { removeField ( type , RemoveButton ) ; } ) ;
32
32
AuthorFieldsCount = AuthorFieldsCount + 1 ;
33
33
}
34
34
else if ( type == "Genre" ) {
35
35
36
36
var OwnershipContainer = $ ( "<div/>" ) . attr ( "class" , "ownership-container" ) . attr ( "id" , "OwnershipContainer" + GenresFieldsCount ) . appendTo ( $ ( "#Genres" ) ) ;
37
37
$ ( "<input/>" ) . attr ( "class" , "text-box single-line" ) . attr ( "type" , "text" ) . attr ( "id" , "Genre" + GenresFieldsCount ) . attr ( "name" , "Genres[" + GenresFieldsCount + "].Genre_Name" ) . attr ( "value" , "" ) . appendTo ( OwnershipContainer ) ;
38
38
var RemoveButton = $ ( "<a/>" ) . attr ( "class" , "remove-field glyphicon glyphicon-remove" ) . attr ( "item" , GenresFieldsCount ) . attr ( "href" , "#" ) . appendTo ( OwnershipContainer ) ;
39
- RemoveButton . click ( function ( ) { RemoveField ( type , RemoveButton ) ; } ) ;
39
+ RemoveButton . click ( function ( ) { removeField ( type , RemoveButton ) ; } ) ;
40
40
GenresFieldsCount ++ ;
41
41
}
42
- return false
43
42
}
44
43
45
- function RemoveField ( type , RemoveButton ) {
44
+ function removeField ( type , RemoveButton ) {
46
45
debugger ;
47
46
var RecalculateStartNum = parseInt ( RemoveButton . attr ( "item" ) ) ;
48
47
var count = 0 ;
@@ -65,10 +64,9 @@ function RemoveField(type, RemoveButton) {
65
64
RecalculateNamesAndIds ( i , type ) ;
66
65
}
67
66
// OwnershipsCount--;
68
- return false ;
69
67
}
70
68
71
- function RecalculateNamesAndIds ( number , type ) {
69
+ function recalculateNamesAndIds ( number , type ) {
72
70
var prevNumber = number - 1 ;
73
71
//скобки "[" и "]" которые присутствуют в id DOM-объекта в jquery селекторе необходим экранировать двойным обратным слэшем \\
74
72
if ( type == "Tag" ) {
@@ -82,5 +80,4 @@ function RecalculateNamesAndIds(number, type) {
82
80
$ ( "#Author" + number + "Middle" ) . attr ( "name" , "BookAuthors[" + prevNumber + "].Middle_Name" ) ;
83
81
$ ( "#Author" + number + "Last" ) . attr ( "name" , "BookAuthors[" + prevNumber + "].Last_Name" ) ;
84
82
}
85
- return false ;
86
83
}
0 commit comments