         complete: (data) -> $(widget.wrapper.$).find('div.cke_widget_element').html(data.responseText)
 
     snippet['init'] = ->
+      for k, v of $(this.wrapper.$).find('div.cke_widget_element').data('snippet-data')
+        this.data[k] = v
+
       this.on 'dialog', (evt) -> @configured = true
       this.on 'data', (evt) -> @loadTemplate(evt.sender) if @configured
-
-    #snippet['data'] = -> 
 
     snippet
 }

      dataType: 'json'
      data: { effective_regions: data }
      async: false
      success: (data) -> 
        console.log 'success!'
        console.log data
}

Regions = {

SaveAll = {
  replaceSnippets: (html) ->
    obj = $('<div>' + html + '</div>')
    obj.find('div[data-snippet-data]').each -> $(this).replaceWith("[#{$(this).data('snippet')}]")
    obj.html()

  instanceData: (instance) ->
    console.log 'INSTANCE DATA'

    snippets = {}

    for id, widget of instance.widgets.instances
      console.log widget
      snippet_id = $(widget.wrapper.$).data('cke-widget-id')
      snippets["snippet_#{snippet_id}"] = widget.data
      snippets["snippet_#{snippet_id}"]['class_name'] = widget.name

      snippet_data = $(widget.element.$).data('snippet-data')
      snippet_data['id'] = snippet_id
      $(widget.element.$).data('snippet-data', snippet_data)

      console.log "WIDGET HTML"
      console.log $(widget.element.$).data('snippet-data')

    content = instance.getData()

    console.log "CONTENT:"
    console.log content

    {
      content: instance.getData(),
      snippets: snippets
    }

  exec: (editor) ->
    data = {}
    data[name] = @instanceData(instance) for name, instance of CKEDITOR.instances

    url = window.location.protocol + '//' + window.location.host + '/edit' + window.location.pathname

    console.log "Saving..."
    console.log data

    $.ajax
      url: url
