Niels
Niels

Reputation: 609

Can't append html to div parent with jquery and backbone

I'm using Backbone marionnete too create some views. Now I need to perform a ajax call to my backend. To make the user clear I perfoming an action I want to show a spinner. My eye felt on this one: spin.js Now before I trigger my ajax call I want to append the spinner to my parent. Therefore I though to use plain jquery and append the el like this

callBackend: ->
  spinner = new Spinner(opts).spin();
  $('.model-content').append(spinner.el);

Now I noticed nothing get's added to to dom. But when I perfom the same command in the browser terminal using debugger so the same spinner instance it draws nicely on the screen. So I know for some reason $('.model-content').append(spinner.el); is behaving like it should. Some body any pointers?

Thanks

Upvotes: 0

Views: 212

Answers (1)

Mschip
Mschip

Reputation: 11

Without seeing the rest of your code, I would guess it has something to do with what you're passing into your spinner. If you are passing in 'opts' remove it. Otherwise, make sure you're passing in an object of options.

Try

spinner = new Spinner().spin();

or

opts = { color: '#000', width: 10 }
spinner = new Spinner(opts).spin();

Upvotes: 1

Related Questions