DmitryEfimenko / TwitterBootstrapMvc

Fluent implementation of ASP.NET-MVC HTML helpers for Twitter Bootstrap.
Apache License 2.0
223 stars 79 forks source link

Carousel WithJs for section #314

Closed wstaelens closed 10 years ago

wstaelens commented 10 years ago

In the carousel you can use .WithJs().

Unfortunately this doesn't work, because the javascript is rendered before my jquery is added which results in an undefined exception.

My Javascript is rendered using section (@section MyJavascript { ... } ) which is rendered in the _Layout at a very specific place at the bottom of the page.

wouldn't it not be great to have an overload like .WithJs(mySectionName) ?

DmitryEfimenko commented 10 years ago

you are right, in the scenario your described there will be an issue. To be honest I'm not a big fun of the method .WithJs(). It inserts 'random' javascript in the middle of html, which I do not like at all. Current implementation also does not allow to just specify a section name to write that JS to. My general suggestion would be to avoid this method and simply write:

$('.carousel').carousel();

in your javascript section. This should solve all the issues regarding this.

wstaelens commented 10 years ago

I first tried the .WithJs() so that I could modify the carousel but now with the data- htmlattribute I don't need the .WithJs() anymore. though it might be a nice addition to the BMVC library. For me you can close this "issue", as it was rather a suggestion to implement.

DmitryEfimenko commented 10 years ago

sounds good. Thanks for thinking of new features though!