Ocelyn
9 May 2012, 2:20 PM
Hello,
A new day, a new question :
I have my XML who looks like this :
<?xml version="1.0" encoding="utf-8" ?>
<data>
<news>
<title><![CDATA[Hello]]></title>
<author><![CDATA[Ocelyn]]></author>
<content><![CDATA[Lorem ipsum]]></content>
<gallery>
<item><![CDATA[<img src="http://www.ocelyn.com/medias/img/iko/iko-1.jpg"/>]]></item>
<item><![CDATA[<img src="http://www.ocelyn.com/medias/img/ag/1.jpg"/>]]></item>
<item><![CDATA[<img src="http://www.ocelyn.com/medias/img/ag/1.jpg"/>]]></item>
</gallery>
</news>
<news>
...
I want to get all my items and insert them inside of an array
So in my model I did something like that :
fields: [
'title',
'author',
'content',
{
name: 'gallery',
convert: function(value, record) {
var arrayItem;
for( var i = 0; i < record.get('gallery').length; i++){
arrayItem[i] = record.get('gallery')[i];
}
return arrayItem;
}
}
]
But it's not working, is it the good way to do it ?
When I'll try to access to my array in my model should I do something like :
record.get('gallery') ?
Thank you for your help
Ocelyn
A new day, a new question :
I have my XML who looks like this :
<?xml version="1.0" encoding="utf-8" ?>
<data>
<news>
<title><![CDATA[Hello]]></title>
<author><![CDATA[Ocelyn]]></author>
<content><![CDATA[Lorem ipsum]]></content>
<gallery>
<item><![CDATA[<img src="http://www.ocelyn.com/medias/img/iko/iko-1.jpg"/>]]></item>
<item><![CDATA[<img src="http://www.ocelyn.com/medias/img/ag/1.jpg"/>]]></item>
<item><![CDATA[<img src="http://www.ocelyn.com/medias/img/ag/1.jpg"/>]]></item>
</gallery>
</news>
<news>
...
I want to get all my items and insert them inside of an array
So in my model I did something like that :
fields: [
'title',
'author',
'content',
{
name: 'gallery',
convert: function(value, record) {
var arrayItem;
for( var i = 0; i < record.get('gallery').length; i++){
arrayItem[i] = record.get('gallery')[i];
}
return arrayItem;
}
}
]
But it's not working, is it the good way to do it ?
When I'll try to access to my array in my model should I do something like :
record.get('gallery') ?
Thank you for your help
Ocelyn