Completed
Pull Request — dev/6.0.0 (#296)
by Rajan
13:51 queued 10:53
created

$(document).ready   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
nc 1
dl 0
loc 6
rs 9.4285
nop 0
1
jQuery( document ).ready( function () {
2
	jQuery( '.select2-post' ).select2( {
3
		width: '300px',
4
		templateSelection: formatLabel
5
	} );
6
});
7
8
function formatLabel (state) {
9
  if (!state.id) {
10
    return state.text;
11
  }
12
  var parentLabel = state.element.parentElement.label;
13
  var $state = jQuery(
14
  	    '<span>' + parentLabel + '-' + state.text + '</span>'
15
  );
16
  return $state;
17
}