FokkeZB / nl.fokkezb.loading

The widget provides a simple loading mask that can be easily styled and configured.
93 stars 18 forks source link

Index.xml must have a top-level containger element #3

Closed dayalav closed 11 years ago

dayalav commented 11 years ago

When I try the example of the widget documentation, receive this error:

[ERROR] : Compile failed. index.xml must have a top-level container element. [ERROR] : Alloy compiler failed

The index.xml is like the README.md of the widget but I can´t attach here.

FokkeZB commented 11 years ago

Could you just copy-paste the index.xml here?

dayalav commented 11 years ago

Here´s the code like the README.md:

<Alloy>
    <Window>
        <Button onClick="load">load</Button>
    </Window>
    <Widget src="nl.fokkezb.loading" id="loading" />
</Alloy>
FokkeZB commented 11 years ago

I don't get the compile error you're having. And you shouldn't, because the view does have a top-level container element, being Window.

But anyway, the next major version will recommend you not to declare it in XML anymore. Instead, declare the widget in your alloy.js by doing:

Alloy.Globals.loading = Alloy.createWidget('nl.fokkezb.loading');

You can then use it anywhere by calling Alloy.Globals.loading.show('My message');

kolchy commented 11 years ago

I get the same error:

[ERROR] Application Installer abnormal process termination. Process exit value was 1
[ERROR] :  Compile failed. index.xml must have a top-level container element.
[ERROR] :  Alloy compiler failed

index.xml

<Alloy>
    <Window id="index" class="container" backgroundColor="black" title="Happiest Hour" onOpen="doOpen" exitOnClose="true">

        <Menu id="menu" platform="android">
            <MenuItem title="Search" onClick="openSearch" icon="Ti.Android.R.drawable.ic_menu_search" showAsAction="Ti.Android.SHOW_AS_ACTION_ALWAYS" />
            <MenuItem title="Sync" onClick="doSync" />
            <MenuItem title="About" onClick="openAbout" />
            <MenuItem title="Support" onClick="openSupport" />
        </Menu>

        <ImageView id="title" image="/img/home/title_trans.png" top="30dp" width="80%" ></ImageView>

        <View height="Ti.UI.FILL">
            <View id="homenav">
                <ImageView image="/img/home/nearby.png" onClick="Alloy.Globals.openSubWindow" controller="venue/nearbyWindow" class="homenavitem" />
                <ImageView image="/img/home/shout.png" onClick="Alloy.Globals.openSubWindow" controller="shout/listWindow" class="homenavitem" />
                <ImageView image="/img/home/search.png" onClick="Alloy.Globals.openSubWindow" controller="venue/searchWindow" class="homenavitem" />
            </View>
        </View>
    </Window>
    <Widget src="nl.fokkezb.loading" id="loading" />
</Alloy>
FokkeZB commented 11 years ago

Looks like in latest Alloy a widget cannot have no view anymore.

I'll keep this one closed and update the README to instruct you to use this in alloy.js instead:

Alloy.Globals.loading = Alloy.createWidget('nl.fokkezb.loading');
kolchy commented 11 years ago

Nice :) Note, in the README you have:

Alloy.Globals = Alloy.createWidget("nl.fokkezb.loading");

Shouldn't that be

Alloy.Globals.loading = Alloy.createWidget("nl.fokkezb.loading");

Do u also need to declare when you use it? eg

var loading = Alloy.Globals.loading;

??

FokkeZB commented 11 years ago

I'm pushing a brand new rewrite of the widget in the next 30m

Yes, it should be Alloy.Globals.loading and no, you do not need to create a new reference everywhere you use it