                         search: (term, callback) ->
                             term = taiga.slugify(term)
 
-                            $rs.search.do($scope.projectId || $scope.vm.projectId, term).then (res) =>
+                            $rs.search.do($scope.project.id, term).then (res) =>
                                 if res.count < 1
                                     callback([])
 

    return {link:link, require:"ngModel"}

module.directive("tgMarkitup", ["$rootScope", "$tgResources", "$selectedText", "$tgTemplate", "$compile",
                                "$translate", MarkitupDirective])

#############################################################################
## WYSIWYG markitup editor directive
#############################################################################
MarkitupDirective = ($rootscope, $rs, $selectedText, $template, $compile, $translate, projectService) ->
    previewTemplate = $template.get("common/wysiwyg/wysiwyg-markitup-preview.html", true)

    link = ($scope, $el, $attrs, $model) ->
        if not $scope.project
            # for backward compatibility
            $scope.project = projectService.project.toJS()

        element = angular.element($el)
        previewDomNode = $("<div/>", {class: "preview"})

