Hi I've tried this solution for a while now and get no success unless I use the given solution, the method setName is always undefined, while code.js is MIME-Type text/plain.
Here is one of many solutions I tried
//Coffeescript
domify = require 'domify'
Widget = () ->
if (!(@ instanceof Widget))
return new Widget()
@element = domify('
Hello !
')
Widget::setName = (name) ->
@element.querySelector('.name').textContent = name
Widget::appendTo = (target) ->
target.appendChild(@element)
module.exports = Widget
I've tried compiling with and without a function wrapper and run it from the .js file
Thanks
Hi I've tried this solution for a while now and get no success unless I use the given solution, the method setName is always undefined, while code.js is MIME-Type text/plain.
Here is one of many solutions I tried
//Coffeescript
domify = require 'domify'
Widget = () ->
if (!(@ instanceof Widget))
return new Widget()
@element = domify('
Widget::setName = (name) ->
@element.querySelector('.name').textContent = name
Widget::appendTo = (target) ->
target.appendChild(@element)
module.exports = Widget
I've tried compiling with and without a function wrapper and run it from the .js file
Thanks