File tree Expand file tree Collapse file tree 2 files changed +74
-6
lines changed Expand file tree Collapse file tree 2 files changed +74
-6
lines changed Original file line number Diff line number Diff line change 265
265
$entry = this . _getMenuEntry ( cmd , false ) ;
266
266
267
267
if ( typeof titleOrData === "string" ) {
268
- // Replace <a> text without removing <span> child
269
- $entry
270
- . contents ( )
271
- . filter ( function ( ) { return this . nodeType === 3 ; } )
272
- . first ( )
273
- . replaceWith ( titleOrData ) ;
268
+ if ( $entry . children ( "span" ) . length ) {
269
+ // Replace <a> text without removing <span> child
270
+ $entry
271
+ . contents ( )
272
+ . filter ( function ( ) { return this . nodeType === 3 ; } )
273
+ . first ( )
274
+ . replaceWith ( titleOrData ) ;
275
+ } else {
276
+ // <a> tag only contains text (above code doesn't work here)
277
+ $entry . text ( titleOrData ) ;
278
+ }
274
279
} else {
275
280
$parent = $entry . closest ( "li" ) . empty ( ) ;
281
+ titleOrData . cmd = titleOrData . cmd || cmd ;
276
282
$ . moogle . contextmenu . createEntryMarkup ( titleOrData , $parent ) ;
277
283
}
278
284
} ,
Original file line number Diff line number Diff line change
1
+ < link type ="text/css " rel ="stylesheet " href ="http://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/start/jquery-ui.css " />
2
+ < script src ="http://code.jquery.com/jquery-1.9.0.min.js "> </ script >
3
+ < script src ="http://code.jquery.com/ui/1.10.2/jquery-ui.js "> </ script >
4
+ < script src ="../jquery.ui-contextmenu.js "> </ script >
5
+
6
+ < style type ="text/css ">
7
+ .hasmenu {
8
+ border : 1px solid # 008 ;
9
+ margin : 3px ;
10
+ padding : 5px ;
11
+ width : 30px ;
12
+ }
13
+ .ui-widget {
14
+ font-size : .8em ;
15
+ }
16
+ table , td {
17
+ border : 1px solid dimgray;
18
+ }
19
+ </ style >
20
+
21
+ < script type ="text/javascript ">
22
+ $ ( document ) . ready ( function ( ) {
23
+
24
+ function action ( event , ui ) {
25
+ console . log ( ui . target ) ;
26
+ } ;
27
+
28
+ $ ( "#details" ) . contextmenu ( {
29
+ delegate : ".hasmenu" ,
30
+ menu : [
31
+ { title : "Option 1 title" , cmd : 'opt1' , action : action } ,
32
+ { title : "-" } ,
33
+ { title : "Option 2 title" , cmd : 'opt2' , action : action }
34
+ ] ,
35
+ beforeOpen : function ( event , ui ) {
36
+ var titleText = 'record ' + ui . target . parent ( ) . attr ( 'record' ) ;
37
+ $ ( "#details" ) . contextmenu ( "setEntry" , "opt1" , { title : titleText } ) ;
38
+ $ ( "#details" ) . contextmenu ( "setEntry" , "opt2" , titleText ) ;
39
+ }
40
+ } ) ;
41
+
42
+ } ) ;
43
+ </ script >
44
+
45
+ < table id ="details " class ="table ">
46
+ < thead >
47
+ < tr >
48
+ < th > Id</ th >
49
+ < th > File Name</ th >
50
+ < tr />
51
+ </ thead >
52
+ < tbody >
53
+ < tr record ="1 " class ="hasmenu ">
54
+ < td > 1</ td >
55
+ < td > Record 1</ td >
56
+ </ tr >
57
+ < tr record ="2 " class ="hasmenu ">
58
+ < td > 2</ td >
59
+ < td > Record 2</ td >
60
+ </ tr >
61
+ </ tbody >
62
+ </ table >
You can’t perform that action at this time.
0 commit comments