jQuery plugin returning its init function rather than the result of calling the plugin -


i'm working snackbarjs jquery plugin. i'm calling in django template so:

<script>     var options = {         content: "testing some snackbar text",         // style: "toast",          timeout: 0,         //htmlallowed: true      };     var test = $.snackbar(options);     console.log('test is: ');     console.log(test); </script> 

i'm requiring plugin using browserify:

var $ = require('jquery'); require('snackbarjs'); 

right now, output of test variable is

jquery.fn.init[1] 

...which believe result of initializing snackbarjs itself. should returning html of snackbar.

when run same snackbar initialization code browser console after page has loaded, runs fine, , test returns <div> of snackbar i'm trying load.

how can snackbar jquery plugin work inside template, , what's going wrong? thanks!

the javascript function calling before dom ready. plugin appends div produces end of dom, , calling while dom still painting, suspect overwrites contents of <div>.

i wrapped call jquery plugin in $(document).ready , works fine.


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

Nuget pack csproj using nuspec -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -