This could be done in a much simpler way today, I think.

I'm using Tapestry 5.4-beta-22 and only the libraries shipped by
Tapestry (Bootstrap, etc.) - love it.
To use Bootstraps popover.js, a component we must initialize ourself, I
only need to do this:

In my Layout component (include the modules as needed):
@Import(module={"bootstrap/collapse", "bootstrap/dropdown",
"bootstrap/popover"}) //<— added "bootstrap/popover" - could have
added "my-js-popover"
here also, and not in the page class
public class Layout
{
. . .
}

In my page class:
public class ListSomething
{
@Inject
private JavaScriptSupport javaScriptSupport;

public void afterRender()
{
javaScriptSupport.require("my-js-popover"); //<— import my js-file from
"src/main/resources/META-INF/modules"

{
. . .
}

In my page ListSomething.tml:
<html t:type="Layout" t:title="literal:List Something"
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_4.xsd";
xmlns:p="tapestry:parameter">
. . .
<button type="button" class="btn btn-lg btn-danger" data-toggle="popover"
id="myPop"
title="Popover title" data-content="And here's some amazing content.">Click
</button>
. . .
</html>

In my "src/main/resources/META-INF/modules/my-js-popover.js":
define(["jquery", "bootstrap/popover"], function($, popover) {
var $pop = $("#myPop");
$pop.popover({placement : 'top'});
});

No changes in the default AppModule.

This is great!

---
Arve Kev

2014-05-27 22:54 GMT+02:00 Basile Chandesris <ba...@free.fr>:

> Since 5.4-alpha-15 , tapestry use Bootstrap 3.x.
>
> https://git-wip-us.apache.org/repos/asf?p=tapestry-5.git;a=tree;h=
> f43e87abf9b77f08b99e90aa22b6d54f20ce7bd1;hb=bb23cdc21f68a655f8f2c24bb8c2c2
> ce5369ca12
>
> http://getbootstrap.com/
> http://getbootstrap.com/2.3.2/
>
> 5.4-beta-6:
>   Bootstrap 3.0.3
> https://git-wip-us.apache.org/repos/asf?p=tapestry-5.git;a=commit;h=
> 234ec514afc376252c5c526e4b2bd3cab6c83a5e
>   jQuery 1.11.1 / 1.9.1
>   RequireJS 2.1.11
> https://git-wip-us.apache.org/repos/asf?p=tapestry-5.git;a=commit;h=
> 5b12cea9f97e12b1433cf960b83e7bcc45bee63d
>  Moment.js 2.6.0
> https://git-wip-us.apache.org/repos/asf?p=tapestry-5.git;a=commit;h=
> 36375f07cb45f6da87434f4c2ba2b010397d0e05
>  Underscore 1.5.2
> https://git-wip-us.apache.org/repos/asf?p=tapestry-5.git;a=commit;h=
> d27925498a3589c8d53fb25b0cdf79e43482f2b0
> Typeahead 0.9.3
> CoffeeScript 1.7.1
> https://git-wip-us.apache.org/repos/asf?p=tapestry-5.git;a=commit;h=
> 218d4c722f15e0f142fa5c05e59b766cad714d0d
>
> https://git-wip-us.apache.org/repos/asf?p=tapestry-5.git;a=
> blob;f=tapestry-core/src/main/java/org/apache/tapestry5/
> modules/JavaScriptModule.java;h=5bf078217acb821cb8628d34bc59cd
> 5c4acd6e23;hb=5bf078217acb821cb8628d34bc59cd5c4acd6e23
>
> Le 26/05/14 18:59, Ilya Obshadko a écrit :
>
>  Turns out I've got "Uncaught TypeError: undefined is not a function" in
>> dom.js, line 134. Don't have any idea where it might come from.
>>
>>
>> On Mon, May 26, 2014 at 8:26 PM, Ilya Obshadko <ilya.obsha...@gmail.com>
>> wrote:
>>
>>  I've just started migrating from 5.3 to 5.4-beta3. My application already
>>> heavily relies on Bootstrap and jQuery. Previously I was using Bootstrap
>>> version 2.3.2, so that's a good time to upgrade Bootstrap as well.
>>>
>>> Could someone clarify this for me: Tapestry 5.4 distribution already
>>> contains everything needed to work out of the box? Or do I have to import
>>> Bootstrap libraries manually? Because all Bootstrap controls just stopped
>>> working, there are no event handlers installed and it seems to me that
>>> bootstrap.js file bundled with Tapestry is very minimal one.
>>>
>>>
>>> --
>>> Ilya Obshadko
>>>
>>>
>>>
>>
>

Reply via email to