<?xml version="1.0" encoding="UTF-8"?>
<ticket>
  <assigned-user-id type="integer">23242</assigned-user-id>
  <attachments-count type="integer">0</attachments-count>
  <closed type="boolean">true</closed>
  <created-at type="datetime">2008-07-02T17:12:43+01:00</created-at>
  <creator-id type="integer">25129</creator-id>
  <milestone-due-on type="datetime" nil="true"></milestone-due-on>
  <milestone-id type="integer">31708</milestone-id>
  <number type="integer">186</number>
  <permalink>asset-css-onload-event-does-not-fire-in-ff3-safari-opera</permalink>
  <priority type="integer">14</priority>
  <project-id type="integer">2706</project-id>
  <raw-data type="binary" nil="true" encoding="base64"></raw-data>
  <state>resolved</state>
  <tag>defect events</tag>
  <title>Asset.css onload event does not fire in FF3, Safari, Opera</title>
  <updated-at type="datetime">2010-02-09T11:13:24+00:00</updated-at>
  <user-id type="integer">22206</user-id>
  <user-name>elado</user-name>
  <creator-name>Stickman</creator-name>
  <assigned-user-name>Aaron Newton</assigned-user-name>
  <url>http://mootools.lighthouseapp.com/projects/2706/tickets/186</url>
  <milestone-title>MooTools-More</milestone-title>
  <original-body>I'm trying to get an onload event to fire when a CSS asset has finished loading. The following code works in IE6:

@@@ javascript
Asset.css(
	'js/mocha/css/mocha.css',
	{
		onload:function()
		{
			alert('Asset loaded');
		}
	}
);
@@@

However, the event is not fired in Firefox 3.0, Safari 3.1.2, or Opera 9.5.0 (all on Windows XP). 

As an experiment, I tried using a modified version of the code for loading javascript assets (i.e. I modified the MooTools Asset class) and had some success getting it to work with Opera, but the changes caused problems in IE and made no difference to FF or Safari.</original-body>
  <latest-body>I'm trying to get an onload event to fire when a CSS asset has finished loading. The following code works in IE6:

@@@ javascript
Asset.css(
	'js/mocha/css/mocha.css',
	{
		onload:function()
		{
			alert('Asset loaded');
		}
	}
);
@@@

However, the event is not fired in Firefox 3.0, Safari 3.1.2, or Opera 9.5.0 (all on Windows XP). 

As an experiment, I tried using a modified version of the code for loading javascript assets (i.e. I modified the MooTools Asset class) and had some success getting it to work with Opera, but the changes caused problems in IE and made no difference to FF or Safari.</latest-body>
  <original-body-html>&lt;div&gt;&lt;p&gt;
I'm trying to get an onload event to fire when a CSS asset has finished loading. The following code works in IE6:
&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;javascript&quot;&gt;Asset.css(
	'js/mocha/css/mocha.css',
	{
		onload:function()
		{
			alert('Asset loaded');
		}
	}
);&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
However, the event is not fired in Firefox 3.0, Safari 3.1.2, or Opera 9.5.0 (all on Windows XP).
&lt;/p&gt;&lt;p&gt;
As an experiment, I tried using a modified version of the code for loading javascript assets (i.e. I modified the MooTools Asset class) and had some success getting it to work with Opera, but the changes caused problems in IE and made no difference to FF or Safari.
&lt;/p&gt;&lt;/div&gt;</original-body-html>
  <versions type="array">
    <version type="Ticket::Version">
      <assigned-user-id type="integer">4325</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>I'm trying to get an onload event to fire when a CSS asset has finished loading. The following code works in IE6:

@@@ javascript
Asset.css(
	'js/mocha/css/mocha.css',
	{
		onload:function()
		{
			alert('Asset loaded');
		}
	}
);
@@@

However, the event is not fired in Firefox 3.0, Safari 3.1.2, or Opera 9.5.0 (all on Windows XP). 

As an experiment, I tried using a modified version of the code for loading javascript assets (i.e. I modified the MooTools Asset class) and had some success getting it to work with Opera, but the changes caused problems in IE and made no difference to FF or Safari.</body>
      <body-html>&lt;div&gt;&lt;p&gt;
I'm trying to get an onload event to fire when a CSS asset has finished loading. The following code works in IE6:
&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;javascript&quot;&gt;Asset.css(
	'js/mocha/css/mocha.css',
	{
		onload:function()
		{
			alert('Asset loaded');
		}
	}
);&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
However, the event is not fired in Firefox 3.0, Safari 3.1.2, or Opera 9.5.0 (all on Windows XP).
&lt;/p&gt;&lt;p&gt;
As an experiment, I tried using a modified version of the code for loading javascript assets (i.e. I modified the MooTools Asset class) and had some success getting it to work with Opera, but the changes caused problems in IE and made no difference to FF or Safari.
&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2008-07-02T17:12:43+01:00</created-at>
      <creator-id type="integer">25129</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">1634</milestone-id>
      <number type="integer">186</number>
      <permalink>asset-css-onload-event-does-not-fire-in-ff3-safari-opera</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">2706</project-id>
      <state>new</state>
      <tag>1.2release defect events plugins</tag>
      <title>Asset.css onload event does not fire in FF3, Safari, Opera</title>
      <updated-at type="datetime">2008-07-02T17:12:43+01:00</updated-at>
      <user-id type="integer">25129</user-id>
      <user-name>Stickman</user-name>
      <creator-name>Stickman</creator-name>
      <assigned-user-name>Valerio</assigned-user-name>
      <url>http://mootools.lighthouseapp.com/projects/2706/tickets/186</url>
      <milestone-title>2.0</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">4325</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>I've created an interim fix for this. It's not perfect because, since it uses XHR, it won't load CSS from a third-party domain. But it works for my purposes and I thought others might find it useful until a proper fix is implemented. 

Simply replace the Assets.css function definition with this:

@@@ javascript
css: function(source, properties){

	// Create a style element instead of a link element
	var style_node = new Element('style', $merge({
		'media': 'screen', 'type': 'text/css'
	}, properties)).inject(document.head);
	// Not sure why this is needed, but it is
	style_node.onload = properties.onload;
	delete properties.onload;

	// Fetch CSS using XHR
	var request = new Request
	(
		{
			method: 'get',
			url: source,
			style_node:style_node,
			onSuccess:function( css_text ){
				// Set the CSS
				// From http://yuiblog.com/blog/2007/06/07/style/
				if (this.styleSheet) {
					this.styleSheet.cssText = css_text;
				} else {
					this.appendChild(document.createTextNode(css_text));
				}
				this.onload();
			}.bind( style_node )
		}
	);
	request.send();

	return style_node;
},
@@@</body>
      <body-html>&lt;div&gt;&lt;p&gt;
I've created an interim fix for this. It's not perfect because, since it uses XHR, it won't load CSS from a third-party domain. But it works for my purposes and I thought others might find it useful until a proper fix is implemented.
&lt;/p&gt;&lt;p&gt;
Simply replace the Assets.css function definition with this:
&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;javascript&quot;&gt;css: function(source, properties){

	// Create a style element instead of a link element
	var style_node = new Element('style', $merge({
		'media': 'screen', 'type': 'text/css'
	}, properties)).inject(document.head);
	// Not sure why this is needed, but it is
	style_node.onload = properties.onload;
	delete properties.onload;

	// Fetch CSS using XHR
	var request = new Request
	(
		{
			method: 'get',
			url: source,
			style_node:style_node,
			onSuccess:function( css_text ){
				// Set the CSS
				// From &lt;a href=&quot;http://yuiblog.com/blog/2007/06/07/style/&quot;&gt;http://yuiblog.com/blog/2007/06/...&lt;/a&gt;
				if (this.styleSheet) {
					this.styleSheet.cssText = css_text;
				} else {
					this.appendChild(document.createTextNode(css_text));
				}
				this.onload();
			}.bind( style_node )
		}
	);
	request.send();

	return style_node;
},&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2008-07-03T10:34:14+01:00</created-at>
      <creator-id type="integer">25129</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">1634</milestone-id>
      <number type="integer">186</number>
      <permalink>asset-css-onload-event-does-not-fire-in-ff3-safari-opera</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">2706</project-id>
      <state>new</state>
      <tag>1.2release defect events plugins</tag>
      <title>Asset.css onload event does not fire in FF3, Safari, Opera</title>
      <updated-at type="datetime">2008-07-03T10:34:14+01:00</updated-at>
      <user-id type="integer">25129</user-id>
      <user-name>Stickman</user-name>
      <creator-name>Stickman</creator-name>
      <assigned-user-name>Valerio</assigned-user-name>
      <url>http://mootools.lighthouseapp.com/projects/2706/tickets/186</url>
      <milestone-title>2.0</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">23242</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body></body>
      <body-html></body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-02-19T00:25:43+00:00</created-at>
      <creator-id type="integer">25129</creator-id>
      <diffable-attributes type="yaml">--- 
:tag: 1.2release defect events plugins
:assigned_user: 4325
:milestone: 1634
</diffable-attributes>
      <milestone-id type="integer">31708</milestone-id>
      <number type="integer">186</number>
      <permalink>asset-css-onload-event-does-not-fire-in-ff3-safari-opera</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">2706</project-id>
      <state>new</state>
      <tag>defect events</tag>
      <title>Asset.css onload event does not fire in FF3, Safari, Opera</title>
      <updated-at type="datetime">2009-02-19T00:25:45+00:00</updated-at>
      <user-id type="integer">23242</user-id>
      <user-name>Aaron Newton</user-name>
      <creator-name>Stickman</creator-name>
      <assigned-user-name>Aaron Newton</assigned-user-name>
      <url>http://mootools.lighthouseapp.com/projects/2706/tickets/186</url>
      <milestone-title>MooTools-More</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">23242</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>We don't currently support onLoad for Asset.css. Do we plan to?</body>
      <body-html>&lt;div&gt;&lt;p&gt;We don't currently support onLoad for Asset.css. Do we plan
to?&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2010-02-08T15:18:53+00:00</created-at>
      <creator-id type="integer">25129</creator-id>
      <diffable-attributes type="yaml">--- 
:state: new
</diffable-attributes>
      <milestone-id type="integer">31708</milestone-id>
      <number type="integer">186</number>
      <permalink>asset-css-onload-event-does-not-fire-in-ff3-safari-opera</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">2706</project-id>
      <state>open</state>
      <tag>defect events</tag>
      <title>Asset.css onload event does not fire in FF3, Safari, Opera</title>
      <updated-at type="datetime">2010-02-08T15:18:54+00:00</updated-at>
      <user-id type="integer">32379</user-id>
      <user-name>fakedarren</user-name>
      <creator-name>Stickman</creator-name>
      <assigned-user-name>Aaron Newton</assigned-user-name>
      <url>http://mootools.lighthouseapp.com/projects/2706/tickets/186</url>
      <milestone-title>MooTools-More</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">23242</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>Sorry it took so long to get to this ticket; -more tickets really belong in the dedicated MooTools More Lighthouse: https://mootools.lighthouseapp.com/projects/24057-mootoolsmore

fixed for 1.2.4.4</body>
      <body-html>&lt;div&gt;&lt;p&gt;Sorry it took so long to get to this ticket; -more tickets
really belong in the dedicated MooTools More Lighthouse: &lt;a href=
&quot;https://mootools.lighthouseapp.com/projects/24057-mootoolsmore&quot;&gt;https://mootools.lighthouseapp.com/projects/24057-mootoolsmore&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;fixed for 1.2.4.4&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2010-02-09T09:24:47+00:00</created-at>
      <creator-id type="integer">25129</creator-id>
      <diffable-attributes type="yaml">--- 
:state: open
</diffable-attributes>
      <milestone-id type="integer">31708</milestone-id>
      <number type="integer">186</number>
      <permalink>asset-css-onload-event-does-not-fire-in-ff3-safari-opera</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">2706</project-id>
      <state>resolved</state>
      <tag>defect events</tag>
      <title>Asset.css onload event does not fire in FF3, Safari, Opera</title>
      <updated-at type="datetime">2010-02-09T09:24:50+00:00</updated-at>
      <user-id type="integer">23242</user-id>
      <user-name>Aaron Newton</user-name>
      <creator-name>Stickman</creator-name>
      <assigned-user-name>Aaron Newton</assigned-user-name>
      <url>http://mootools.lighthouseapp.com/projects/2706/tickets/186</url>
      <milestone-title>MooTools-More</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">23242</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>Does the fix support cross domain urls?

If not, please consider using this:
http://nb.io/hacks/csshttprequest</body>
      <body-html>&lt;div&gt;&lt;p&gt;Does the fix support cross domain urls?&lt;/p&gt;
&lt;p&gt;If not, please consider using this:&lt;br&gt;
&lt;a href=
&quot;http://nb.io/hacks/csshttprequest&quot;&gt;http://nb.io/hacks/csshttprequest&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2010-02-09T11:13:24+00:00</created-at>
      <creator-id type="integer">25129</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">31708</milestone-id>
      <number type="integer">186</number>
      <permalink>asset-css-onload-event-does-not-fire-in-ff3-safari-opera</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">2706</project-id>
      <state>resolved</state>
      <tag>defect events</tag>
      <title>Asset.css onload event does not fire in FF3, Safari, Opera</title>
      <updated-at type="datetime">2010-02-09T11:13:24+00:00</updated-at>
      <user-id type="integer">22206</user-id>
      <user-name>elado</user-name>
      <creator-name>Stickman</creator-name>
      <assigned-user-name>Aaron Newton</assigned-user-name>
      <url>http://mootools.lighthouseapp.com/projects/2706/tickets/186</url>
      <milestone-title>MooTools-More</milestone-title>
    </version>
  </versions>
</ticket>
