{"action":"created","issue":{"url":"https://api.github.com/repos/TheCoder4eu/BootsFaces-OSP/issues/958","repository_url":"https://api.github.com/repos/TheCoder4eu/BootsFaces-OSP","labels_url":"https://api.github.com/repos/TheCoder4eu/BootsFaces-OSP/issues/958/labels{/name}","comments_url":"https://api.github.com/repos/TheCoder4eu/BootsFaces-OSP/issues/958/comments","events_url":"https://api.github.com/repos/TheCoder4eu/BootsFaces-OSP/issues/958/events","html_url":"https://github.com/TheCoder4eu/BootsFaces-OSP/issues/958","id":333716231,"node_id":"MDU6SXNzdWUzMzM3MTYyMzE=","number":958,"title":"'moment is not defined' when using DateTimePicker in sub page with Primefaces","user":{"login":"TheTimeWalker","id":8660693,"node_id":"MDQ6VXNlcjg2NjA2OTM=","avatar_url":"https://avatars1.githubusercontent.com/u/8660693?v=4","gravatar_id":"","url":"https://api.github.com/users/TheTimeWalker","html_url":"https://github.com/TheTimeWalker","followers_url":"https://api.github.com/users/TheTimeWalker/followers","following_url":"https://api.github.com/users/TheTimeWalker/following{/other_user}","gists_url":"https://api.github.com/users/TheTimeWalker/gists{/gist_id}","starred_url":"https://api.github.com/users/TheTimeWalker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheTimeWalker/subscriptions","organizations_url":"https://api.github.com/users/TheTimeWalker/orgs","repos_url":"https://api.github.com/users/TheTimeWalker/repos","events_url":"https://api.github.com/users/TheTimeWalker/events{/privacy}","received_events_url":"https://api.github.com/users/TheTimeWalker/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-06-19T15:10:52Z","updated_at":"2018-06-19T20:32:37Z","closed_at":null,"author_association":"NONE","body":"**Overview**\r\nThere's currently a bug using Bootsfaces in combination with PrimeFaces when using modules like DateTimePicker in a subpage. Whenever an ajax request is done to change a content to a different sub-page, You then end up with an error in the JS console:\r\n\r\n- `jQuery.Deferred exception: moment is not defined @[url]/:1:235\r\nj@[url]/javax.faces.resource/jquery/jquery.js.xhtml?ln=primefaces&v=6.2:2:29997\r\ng/</k<@[url]/jquery/jquery.js.xhtml?ln=primefaces&v=6.2:2:30313\r\njquery.js.xhtml:2:31569`\r\n\r\n- `ReferenceError: moment is not defined`\r\n\r\nIt seems like that this happens in connection with Primefaces as the error exception mentions the jQuery resource from Primefaces itself.\r\n\r\n**Reproducing the error** \r\n- Create a template page with a dynamic content using \\<ui:include\\> and for example a navigation bean\r\n- Create a subpage with <b:dateTimePicker> in it\r\n- Add a commandLink/navLink/etc. on the main page that does an ajax request to change the content page to the one with dateTimePicker\r\n- Run the app, the console should throw an error and the DateTimePicker is not useable as the button does nothing\r\n\r\n**Other resources**\r\nIt's probably a longer standing bug as there's a StackOverflow question where an user had a similar issue with that. He managed to fix this by manually loading his own moment.js and DateTimePicker.js files.\r\n\r\nLink: https://stackoverflow.com/questions/39620172/using-bootsfaces-datetimepicker\r\n\r\n**Using**\r\n- BootsFaces 1.2.0\r\n- PrimeFaces 6.2\r\n- Payara 5.181.0"},"comment":{"url":"https://api.github.com/repos/TheCoder4eu/BootsFaces-OSP/issues/comments/398535568","html_url":"https://github.com/TheCoder4eu/BootsFaces-OSP/issues/958#issuecomment-398535568","issue_url":"https://api.github.com/repos/TheCoder4eu/BootsFaces-OSP/issues/958","id":398535568,"node_id":"MDEyOklzc3VlQ29tbWVudDM5ODUzNTU2OA==","user":{"login":"stephanrauh","id":3045767,"node_id":"MDQ6VXNlcjMwNDU3Njc=","avatar_url":"https://avatars1.githubusercontent.com/u/3045767?v=4","gravatar_id":"","url":"https://api.github.com/users/stephanrauh","html_url":"https://github.com/stephanrauh","followers_url":"https://api.github.com/users/stephanrauh/followers","following_url":"https://api.github.com/users/stephanrauh/following{/other_user}","gists_url":"https://api.github.com/users/stephanrauh/gists{/gist_id}","starred_url":"https://api.github.com/users/stephanrauh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stephanrauh/subscriptions","organizations_url":"https://api.github.com/users/stephanrauh/orgs","repos_url":"https://api.github.com/users/stephanrauh/repos","events_url":"https://api.github.com/users/stephanrauh/events{/privacy}","received_events_url":"https://api.github.com/users/stephanrauh/received_events","type":"User","site_admin":false},"created_at":"2018-06-19T20:32:37Z","updated_at":"2018-06-19T20:32:37Z","author_association":"COLLABORATOR","body":"Most likely it's not the fault of PrimeFaces (although PrimeFaces has a feature addressing exactly that problem). When you JSF page is initially rendered, it doesn't know it's going to contain a `b:dateTimePicker` at some time in future. So it doesn't load the JavaScript libraries needed by the `b:dateTimePicker`.\r\n\r\nCurrently, the recommended solution is to add a hidden `b:dateTimePicker` to the front page (the page containing the `<ui:include>`). Setting `rendered=\"false\"` guarantees that the extra `b:dataTimePicker` doesn't do anything exception loading the JavaScript libraries. In your case, it should load `moment.js`.\r\n\r\nDoes this solve your problem? Please report back so we can close the ticket (and answer the question on StackOverflow)."}}
{"actor":{"display_login":"stephanrauh"}}