javscript

Hi, 

I'm trying to create a widget composed of a more js files that are all connected to eatch other, and they will need to call functions from eatch other.

What development pattern can I follow in Telligent, to make one JS file aware of another without bringing in .vm files?

I have tried injecting IIFE into another following the module pattern but it doesn't work, should I use something like require.js?

Best Regards,

Silviu

Parents
  • Hi Silviu, i think you're looking for #registerEndOfPageHtml()... a lot of default widgets include at least one js file this way, see any of them for syntax help. Abuse Appeal, for example:

            #registerEndOfPageHtml('telligent.evolution.widgets.abuseAppeal')
                <script type="text/javascript" src="$core_v2_encoding.HtmlAttributeEncode($core_v2_widget.GetFileUrl("ui.js"))"></script>
            #end

  • Yes but if I have multiple js files references like so:

    #registerEndOfPageHtml('telligent.evolution.widgets.js.one')
    <script type="text/javascript" src="$core_v2_encoding.HtmlAttributeEncode($core_v2_widget.GetFileUrl("file1.js"))"></script>
    #end
    
    #registerEndOfPageHtml('telligent.evolution.widgets.js.two')
    <script type="text/javascript" src="$core_v2_encoding.HtmlAttributeEncode($core_v2_widget.GetFileUrl("file2.js"))"></script>
    #end

    How do I make file1.js aware of file2.js ? And the public functions and properties of file2.js available in file1.js?

    Does setting the namespace (telligent.evolution.widgets.js) do the trick?

Reply
  • Yes but if I have multiple js files references like so:

    #registerEndOfPageHtml('telligent.evolution.widgets.js.one')
    <script type="text/javascript" src="$core_v2_encoding.HtmlAttributeEncode($core_v2_widget.GetFileUrl("file1.js"))"></script>
    #end
    
    #registerEndOfPageHtml('telligent.evolution.widgets.js.two')
    <script type="text/javascript" src="$core_v2_encoding.HtmlAttributeEncode($core_v2_widget.GetFileUrl("file2.js"))"></script>
    #end

    How do I make file1.js aware of file2.js ? And the public functions and properties of file2.js available in file1.js?

    Does setting the namespace (telligent.evolution.widgets.js) do the trick?

Children