Results 1 to 17 of 17
  1.    #1  
    I'm making an RSS feed application and I'm trying to figure out how I can build a list dynamically.

    Code:
    this.controller.setupWidget("headlines",
             this.attributes = {
                 itemTemplate: 'first/list-scene',
                 swipeToDelete: false,
                 reorderable: false,
             },
             this.model = {
                 listTitle: $L('Headlines'),
                 items : []
    			 });
    
    var request = new Ajax.Request("feedurl", {
    			method: 'get',
    			onSuccess: function(transport){
    				var items = transport.responseText;
    					var splitFirst = items.split("^^");
    					var splitNum = splitFirst.length;
    					for(var i = 0; i <= 1; i++)
    					{
    						var tempSplit = splitFirst[i].split("||");
    						this.model.items.push({title:tempSplit[0], link:tempSplit[1]});
    						//this.itemsBuilt.push({title:"text", link:"link"});
    					}
    			}
    			});
    Thank is currently what I have but the list won't update and it is being parsed correctly too. I'm about ready to rip my hair out after about 5 hours of trying to figure this stupid thing out.

    (I can't post links apparently and it detected a link in my code so the feedurl is correct though. lol
  2.    #2  
    I noticed that if I just set some static items in the list then it will show properly, it is almost like it just doesn't update after the items are added to the list.
  3. ufergus's Avatar
    Posts
    49 Posts
    Global Posts
    148 Global Posts
    #3  
    I haven't done this myself but I think you need to call a function to tell the gui to recognize the new items. Look up the SceneController function modelChanged.

    Hope this helps.

    rich
  4.    #4  
    Would it be something like this...

    Code:
    Mojo.Controller.setWidgetModel('headlines', this.model);
  5. #5  
    For Internalz, I used the modelChanged function:
    Code:
    this.controller.modelChanged(this.fileListModel);
    Keep in mind the model needs to be the original object used in the SetupWidget() function, just with changed items array contents
  6.    #6  
    Ok I can't figure this out, I've tried everything (or at least I think). It just isn't updating! Nothing that I have tried makes the actual content show up in the list. I am starting to get really confused about this now.
  7.    #7  
    Ok, I'm about to give up (not really). But I'm seriously frustrated. Here is ALL of my code.

    Code:
    function FirstAssistant() {
    	
    }
    
    FirstAssistant.prototype.setup = function() {
    	this.controller.setupWidget("search",
             this.attributes = {
                 hintText: $L('Enter query and press enter...'),
                 multiline: false,
                 enterSubmits: true,
                 focus: true
             },
             this.model = {
                 value: "",
                 disabled: false
        });
    	
    	this.controller.setupWidget("scrollerId",
             this.attributes = {
                 mode: 'vertical'
             });
    	this.modelA = {
                 items : []
    			 };
    	this.controller.setupWidget("headlines",
             this.attributes = {
                 itemTemplate: 'first/list-scene',
                 swipeToDelete: false,
                 reorderable: false,
             },
             this.modelA);
    	var request = new Ajax.Request("linkBlocked >_>", {
    			method: 'get',
    			onSuccess: function(transport){
    				var items = transport.responseText;
    					var splitFirst = items.split("^^");
    					var splitNum = splitFirst.length;
    					var itemBuild = [];
    					for(var i = 0; i <= 1; i++)
    					{
    						var tempSplit = splitFirst[i].split("||");
    						itemBuild.push({title:tempSplit[0], link:tempSplit[1]});
    					}
    					this.modelA["items"] = itemBuild;
    					this.controller.modelChanged(this.modelA);
    			}
    			});
    }
    FirstAssistant.prototype.activate = function(event) {
    	/* put in event handlers here that should only be in effect when this scene is active. For
    	   example, key handlers that are observing the document */
    }
    
    
    FirstAssistant.prototype.deactivate = function(event) {
    	/* remove any event handlers you added in activate and do any other cleanup that should happen before
    	   this scene is popped or another scene is pushed on top */
    }
    
    FirstAssistant.prototype.cleanup = function(event) {
    	/* this function should do any cleanup needed before the scene is destroyed as 
    	   a result of being popped off the scene stack */
    }
  8. #8  
    Code:
    function FirstAssistant() {}
    
    FirstAssistant.prototype.setup = function() {
            /* Search Widget! */
    	this.controller.setupWidget("search",
            this.attributes = {
                 hintText: $L('Enter query and press enter...'),
                 multiline: false,
                 enterSubmits: true,
                 focus: true },
    
             this.model = {
                 value: "",
                 disabled: false
            });
    
    	/* Scroller Widget! */
    	this.list_items = [];
    	this.modelA = { items : this.list_items }
    	
    	this.controller.setupWidget("scrollerId",
            this.attributes = { 
    		mode: 'vertical'}); //Missing a model???
    
            /* Headlines Widget! */
    	this.controller.setupWidget("headlines",
            this.attributes = {
                 itemTemplate: 'first/list-scene',
                 swipeToDelete: false,
                 reorderable: false,
             },
             this.modelA);
    	
    
      var request = new Ajax.Request("linkBlocked >_>", {
    	method: 'get',
    	onSuccess: function(transport){
    		var items = transport.responseText;
    		var splitFirst = items.split("^^");
    		var splitNum = splitFirst.length;
    			itemBuild = new Array();
    				for(var i = 0; i <= 1; i++) {
    				var tempSplit = splitFirst[i].split("||");
    				itemBuild.push({title:tempSplit[0], link:tempSplit[1]});
    				}
    			for(var i =0; i<itemBuild.length; i++) {
    				this.list_items[i] = itemBuild[i];
    			}
    			this.controller.modelChanged(this.modelA, this);
    	}
      });
    
    }
    FirstAssistant.prototype.activate = function(event) {}
    
    FirstAssistant.prototype.deactivate = function(event) {}
    
    FirstAssistant.prototype.cleanup = function(event) {}
    Try that, i'm at work so i can't fully test this out, when i get home i can pull up my code that does
    the same exact thing.
    Last edited by Phrozen; 09/01/2009 at 08:00 AM.
  9. drnull's Avatar
    Posts
    570 Posts
    Global Posts
    571 Global Posts
    #9  
    Don't forget the bind!
    Code:
    			this.controller.modelChanged(this.modelA, this);
    	}
      }.bind(this));
  10.    #10  
    Thanks for all the replies, I've tried everyone's suggestion and Phrozen's was the closest to working.

    Code:
    <div id="main" class="palm-hasheader">
    		<div class="palm-header">preNews</div>
    		<div align="center" id="results" class="palm-body-text">
            <div class="palm-group">
    <div align="left" class="palm-group-title" x-mojo-loc=''>Search</div>
    	<div class="palm-list">
       		<div class="palm-row single">
    			<div class="palm-row-wrapper textfield-group" x-mojo-focus-highlight="true">
    				<div class="title">
          				<div id="search" name="search"  x-mojo-element="TextField"></div>
    				</div>
    			</div>
    		</div>
    	</div>
    </div>
    <div id="scrollerContainer"> 
    	<div id='top' x-mojo-scroll-fade='top' class="scroll-example-top"></div>
    	<div id='bottom' x-mojo-scroll-fade='bottom' class="scroll-example-bottom"></div>   
    	<div id="scroller_holder" x-mojo-element="Scroller">
        <div class="palm-group">
        <div align="left" class="palm-group-title" x-mojo-loc=''>Headlines</div>
    		<div id="scrolling_contents">
            <div class="palm-row single">
            <div class="palm-row-wrapper list-group" x-mojo-focus-highlight="true">
    				<div class="title">
          				<div x-mojo-element="List" id="headlines" name="headlines"></div>
    				</div>
    			</div>
    		</div>
            </div>
    	</div>	
    </div>
    </div>
    There could be something wrong with this code I suppose, which is the first-scene.html. If I use Mojo.Controller.errorMessage and have it show what is being parsed it shows that it is being parsed correctly. As you can tell I'm obviously a noob to the Mojo framework so this is just really confusing for me.
  11. #11  
    In your HeadLines Item template you should have it listed something like this

    Code:
    <div class="palm-row">
    #{title}
    #{-link}
    </div>
    Last edited by Phrozen; 09/01/2009 at 02:07 PM.
  12.    #12  
    Wow it still isn't working..

    This is my list item template file
    Code:
    <div class='result row' x-mojo-tap-highlight='momentary'>
    <a href="#{link}">
    	<div class="palm-list">#{title}</div>
        </a>
    </div>
  13. #13  
    Quote Originally Posted by clacombe View Post
    Wow it still isn't working..

    This is my list item template file
    Code:
    <div class='result row' x-mojo-tap-highlight='momentary'>
    <a href="#{link}">
    	<div class="palm-list">#{title}</div>
        </a>
    </div>
    Why not:
    Code:
    <div class='result row' x-mojo-tap-highlight='momentary'>
    <a href="#{-link}">
    	<div class="palm-list">#{-title}</div>
        </a>
    </div>
  14.    #14  
    It still doesn't work... It will only show static information that I would have to enter manually into the code.

    I'm using Phrozen's code btw.
  15.    #15  
    The url is http://kandutech.com/preNews/feed.aspx. I'm 99.99% positive there isn't anything wrong with it.
  16. #16  
    Try this
    Code:
      var request = new Ajax.Request(myURL, {
    	method: 'get',
    	onSuccess: this.AjaxSuccess.bind(this),
    	onFailure: function(){ Mojo.Log.error("Ut Oh, we got an Error in the Ajax Request"); }
    
    }
    Code:
    FirstAssistant.prototype.AjaxSuccess = function(transport) {
    	var xmlString = transport.responseText;
    	  itemSplit = xmlString.split("^^");
    	 
    	itemBuild = new Array();
    	 for (var i = 0; i < 1; i++) {
    	 	tempSplit = itemSplit[i].split("||");
    		itemBuild.push({
    			title: tempSplit[i][0],
    			link: tempSplit[i][1],
    		});
    	 }
    	 for(var i = 0; i < itemBuild.length; i++) {
    	 	this.list_items = itemBuild[i];
    	 }
    	 this.controller.modelChanged(this.modelA, this);
    Mojo.Log.info("***this.list_items:", this.list_items[0].title); //If you see nothing then there is an issue somewhere.
    }
  17.    #17  
    Thanks for the replies but nothing I have tried has worked. I think I'm just going to start on a tip calculator instead. Thanks to everyone that helped!

Tags for this Thread

Posting Permissions