# Class: NoteContextAwareWidget

## NoteContextAwareWidget()

This widget allows for changing and updating depending on the active note.

## Constructor

#### new NoteContextAwareWidget()

Source:
  - widgets/note_context_aware_widget.js, line 8

### Extends

- BasicWidget

### Members

#### hoistedNoteId

Source:
  - widgets/note_context_aware_widget.js, line 42

#### note

Source:
  - widgets/note_context_aware_widget.js, line 27

#### noteContext :NoteContext

##### Type:

- NoteContext

Source:
  - widgets/note_context_aware_widget.js, line 123

#### noteId

Source:
  - widgets/note_context_aware_widget.js, line 32

#### notePath

Source:
  - widgets/note_context_aware_widget.js, line 37

### Methods

#### css(name, value)

Sets the CSS attribute of the given name to the given value.

##### Parameters:

Name | Type | Description
--- | --- | ---
`name` | string | the name of the CSS attribute to set (e.g. `padding-left`).
`value` | string | the value of the CSS attribute to set (e.g. `12px`).

Inherited From:
  - BasicWidget#css
Source:
  - widgets/basic_widget.js, line 75

##### Returns:

self for chaining.

#### cssBlock(block) → {this}

Accepts a string of CSS to add with the widget.

##### Parameters:

Name | Type | Description
--- | --- | ---
`block` | string |

Inherited From:
  - BasicWidget#cssBlock
Source:
  - widgets/basic_widget.js, line 118

##### Returns:

for chaining

Type
  this

#### doRender()

Method used for rendering the widget. Your class should override this method. The method is expected to create a this.$widget containing jQuery object

Inherited From:
  - BasicWidget#doRender
Source:
  - widgets/basic_widget.js, line 209

#### isEnabled() → {boolean}

Indicates if the widget is enabled. Widgets are enabled by default. Generally setting this to `false` will cause the widget not to be displayed, however it will still be available on the DOM but hidden.

If the widget is not enabled, it will not receive `refreshWithNote` updates.

Overrides:
  - BasicWidget#isEnabled
Source:
  - widgets/note_context_aware_widget.js, line 58

##### Returns:

true when an active note exists

Type
  boolean

#### optChild(condition, …components)

Conditionally adds the given components as children to this component.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`condition` | boolean |  | whether to add the components.
`components` | any | <repeatable> | the components to be added as children to this component provided the condition is truthy.

Inherited From:
  - BasicWidget#optChild
Source:
  - widgets/basic_widget.js, line 50

##### Returns:

self for chaining.

#### optCss(condition, name, value)

Sets the CSS attribute of the given name to the given value, but only if the condition provided is truthy.

##### Parameters:

Name | Type | Description
--- | --- | ---
`condition` | boolean | `true` in order to apply the CSS, `false` to ignore it.
`name` | string | the name of the CSS attribute to set (e.g. `padding-left`).
`value` | string | the value of the CSS attribute to set (e.g. `12px`).

Inherited From:
  - BasicWidget#optCss
Source:
  - widgets/basic_widget.js, line 88

##### Returns:

self for chaining.

#### (async) refreshWithNote(note) → {Promise.<void>}

Override this method to be able to refresh your widget with each note.

##### Parameters:

Name | Type | Description
--- | --- | ---
`note` | FNote |

Source:
  - widgets/note_context_aware_widget.js, line 88

##### Returns:

Type
  Promise.<void>