[Neos] Event when Neos reloads content

Jan-Erik Revsbech janerik at moc.net
Tue Aug 27 19:35:04 CEST 2013


If IE9+ is the only IE to support, then I think this is by far the best 
solutions.

I'll create a patch-set with that, and create some examples on how to 
use it.

/janerik

> ------------------------------------------------------------------------
>
> 	Aske Ertmann <mailto:aske at moc.net>
> August 27, 2013 6:39 PM
>
>
> Hello
>
> After discussing this with Jan-Erik I couldn't resist trying out 
> custom events. And from what I could gather this is pretty straight 
> forward, even for IE9+ compatibility, without any need for relying on 
> some library.
>
> I've put together a small sample http://jsfiddle.net/ExFnE/1/ and 
> tested it in Chrome (OS X), Firefox (OS X), Safari (OS X), IE9 
> (native), IE10 (native) where it works.
>
> There are some minor changes if there's need for IE8 support, but 
> currently I don't think we will support that browser anyway and if we 
> want to at some point I'd be happy to write the necessary fallbacks..
>
> I like this approach better than relying on jQuery even if we could 
> make it work with exposing the RequireJS version somehow and I also 
> think it's better than exposing some global callback/event handler 
> function/object.
>
> Aske
>
>
> _______________________________________________
> Neos mailing list
> Neos at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/neos
> ------------------------------------------------------------------------
>
> 	Christian Müller <mailto:christian.mueller at typo3.org>
> August 27, 2013 9:04 AM
>
>
> Jan-Erik Revsbech wrote:
>>
>>
>>> ------------------------------------------------------------------------ 
>>>
>>>
>>> Jan-Erik Revsbech <mailto:janerik at moc.net>
>>> August 26, 2013 8:40 PM
>>>
>>>
>>> I just made a small test and there is no problem with triggering
>>> events with something like
>>>
>>> $(document).trigger('T3.Neos.Event.PageLoaded');
>>>
>> Actually it did not work like this, but only with
>> jQuery(document).trigger('T3.Neos.Event.PageLoaded'); so I guess the
>> communication between the encapsulated jQuery and the site jQuery
>> provides some challenges. Will have to look into that.
>
> Mmmm, seems so, normally I would expect an event to be an event. But 
> then you probably used your outside jQuery to bind the event. That 
> wouldn't work for sites without jQuery. Maybe plain JS could be used?
>
>>
>>
>>> and then listeting for this events from the Site JS.
>>>
>>> What is the preferred naming of the event names? Then I'll create a
>>> patch for this.
>
> We want to get rid of the T3 eventually but I think the rest sounds 
> just fine. So something like 'Neos.Event.PageLoaded'. Thank you for 
> taking care!
> _______________________________________________
> Neos mailing list
> Neos at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/neos
> ------------------------------------------------------------------------
>
> 	Christian Müller <mailto:christian.mueller at typo3.org>
> August 27, 2013 9:01 AM
>
>
> Jan-Erik Revsbech wrote:
>>
>>
>>> ------------------------------------------------------------------------ 
>>>
>>>
>>> Jan-Erik Revsbech <mailto:janerik at moc.net>
>>> August 26, 2013 8:40 PM
>>>
>>>
>>> I just made a small test and there is no problem with triggering
>>> events with something like
>>>
>>> $(document).trigger('T3.Neos.Event.PageLoaded');
>>>
>> Actually it did not work like this, but only with
>> jQuery(document).trigger('T3.Neos.Event.PageLoaded'); so I guess the
>> communication between the encapsulated jQuery and the site jQuery
>> provides some challenges. Will have to look into that.
>
> Mmmm, seems so, normally I would expect an event to be an event. But 
> then you probably used your outside jQuery to bind the event. That 
> wouldn't work for sites without jQuery. Maybe plain JS could be used?
>
>>
>>
>>> and then listeting for this events from the Site JS.
>>>
>>> What is the preferred naming of the event names? Then I'll create a
>>> patch for this.
>
> We want to get rid of the T3 eventually but I think the rest sounds 
> just fine. So something like 'Neos.Event.PageLoaded'. Thank you for 
> taking care!
> _______________________________________________
> Neos mailing list
> Neos at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/neos
> ------------------------------------------------------------------------
>
> 	Jan-Erik Revsbech <mailto:janerik at moc.net>
> August 26, 2013 9:15 PM
>
>
>
>
>> ------------------------------------------------------------------------
>>
>>     Jan-Erik Revsbech <mailto:janerik at moc.net>
>> August 26, 2013 8:40 PM
>>
>>
>> I just made a small test and there is no problem with triggering 
>> events with something like
>>
>> $(document).trigger('T3.Neos.Event.PageLoaded');
>>
> Actually it did not work like this, but only with 
> jQuery(document).trigger('T3.Neos.Event.PageLoaded');  so I guess the 
> communication between the encapsulated jQuery and the site jQuery 
> provides some challenges. Will have to look into that.
>
>
>> and then listeting for this events from the Site JS.
>>
>> What is the preferred naming of the event names? Then I'll create a 
>> patch for this.
>>
>> Regards
>> Jan-Erik Revsbech
>> MOC
>>
>> _______________________________________________
>> Neos mailing list
>> Neos at lists.typo3.org
>> http://lists.typo3.org/cgi-bin/mailman/listinfo/neos
>> ------------------------------------------------------------------------
>>
>>     Christopher Hlubek <mailto:hlubek at networkteam.com>
>> August 26, 2013 9:24 AM
>>
>>
>> Hi,
>>
>> yes that's very important for websites with JS. I would prefer to 
>> fire custom events on the window / document on:
>>
>> - content reload
>> - switch to preview mode
>> - switch back from preview mode
>> - selecting / editing a node
>> - unselecting a node
>>
>> The events should be namespaced and documented for integrators to 
>> adapt the JS to work with the Neos UI.
>> We just need to make sure that we check if the site JS can 
>> communicate with the encapsulated jQuery we use through RequireJS.
>>
>> Greetings,
>>
>> Christopher
>>
>>
>> _______________________________________________
>> Neos mailing list
>> Neos at lists.typo3.org
>> http://lists.typo3.org/cgi-bin/mailman/listinfo/neos
>> ------------------------------------------------------------------------
>>
>>     Christian Müller <mailto:christian.mueller at typo3.org>
>> August 26, 2013 8:41 AM
>>
>>
>> Hi Jan-Erik,
>>
>> Jan-Erik Revsbech wrote:
>>> Hi all. I have a question I hope one of you awesome guys can helt me
>>> with. On a new Neos site I'm working on, I have a need to trigger some
>>> DOM manipulation via jQuery whenever the content is being reloaded by
>>> Neos (ie. saving a property in the inspector panel). Don't ask why:(
>>
>> Why? ;) Well probably some JS init...
>>
>>>  From what I kan see with my very limited knowledge of the Neos 
>>> backend,
>>> an event is triggered via that.trigger('pageLoaded') in Application.js,
>>> but I have no idea about how to catch that event anywhere. And I might
>>> not even be on the right track here.
>>
>> That is correct. The problem is that this event "pageLoaded" is 
>> triggered on an object that is purely internal and not accessible 
>> from the outside. I think that has to change to allow exactly what 
>> you want because that will be a common usecase with JS enriched 
>> websites.
>>
>>>
>>> So the question is: Is it possible to register a callback function or
>>> otherwise "hook in" whenever the pagecontent is relaoded by Neos?
>>
>> So from what I see it is currently not possible but we should change 
>> that.
>>
>>>
>>> Regards
>>> Jan-Erik Revsbech
>>> MOC
>>
>> Cheers,
>> Christian
>> _______________________________________________
>> Neos mailing list
>> Neos at lists.typo3.org
>> http://lists.typo3.org/cgi-bin/mailman/listinfo/neos
>> ------------------------------------------------------------------------
>>
>>     Jan-Erik Revsbech <mailto:janerik at moc.net>
>> August 25, 2013 5:50 PM
>>
>>
>> Hi all. I have a question I hope one of you awesome guys can helt me 
>> with. On a new Neos site I'm working on, I have a need to trigger 
>> some DOM manipulation via jQuery whenever the content is being 
>> reloaded by Neos (ie. saving a property in the inspector panel). 
>> Don't ask why:(
>>
>> From what I kan see with my very limited knowledge of the Neos 
>> backend, an event is triggered via that.trigger('pageLoaded') in 
>> Application.js, but I have no idea about how to catch that event 
>> anywhere. And I might not even be on the right track here.
>>
>> So the question is: Is it possible to register a callback function or 
>> otherwise "hook in" whenever the pagecontent is relaoded by Neos?
>>
>> Regards
>> Jan-Erik Revsbech
>> MOC
>> _______________________________________________
>> Neos mailing list
>> Neos at lists.typo3.org
>> http://lists.typo3.org/cgi-bin/mailman/listinfo/neos
> _______________________________________________
> Neos mailing list
> Neos at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/neos
> ------------------------------------------------------------------------
>
> 	Jan-Erik Revsbech <mailto:janerik at moc.net>
> August 26, 2013 8:40 PM
>
>
> I just made a small test and there is no problem with triggering 
> events with something like
>
> $(document).trigger('T3.Neos.Event.PageLoaded');
>
> and then listeting for this events from the Site JS.
>
> What is the preferred naming of the event names? Then I'll create a 
> patch for this.
>
> Regards
> Jan-Erik Revsbech
> MOC
>
> _______________________________________________
> Neos mailing list
> Neos at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/neos


More information about the Neos mailing list