1. #1
    Ext User
    Join Date
    Jul 2010
    Posts
    24
    Vote Rating
    0
    uxdan is on a distinguished road

      0  

    Default Create Links for Twitter Example?

    Create Links for Twitter Example?


    I'm fairly new to the whole DataView / Store / Reader concepts, and I was wondering how you might go about converting the twitter example to activate the links within the tweets? Is there a built-in function per chance that would allow a tie in to easily modify a single piece of the json response?

    Thanks!

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,207
    Vote Rating
    858
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    you can use JavaScripts own replace function:

    text.replace(/(http:\/\/)(.*)\s/gi, '<a href=$1$2>$1$2</a>')
    I think that will work, let me know if it doesn't
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Ext User
    Join Date
    Jul 2010
    Posts
    24
    Vote Rating
    0
    uxdan is on a distinguished road

      0  

    Default


    I guess I wasn't as clear... :-(

    I know how to replace it, but I just don't know where i can grab the text. So where would i put that code?

  4. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,207
    Vote Rating
    858
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    a config option for DataView is prepareData which is not in the API Docs for Touch or ExtJS.

    Here is a sample that will take the data for each record in a store, get the value in the created key and format it to a date.

    Code:
    new Ext.DataView({
    	...
    	prepareData  : function(data) {
    		data.created = Ext.util.Format.date(new Date(data.created), "m-d-Y");
    		return data;
    	}
    })
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  5. #5
    Ext User
    Join Date
    Jul 2010
    Posts
    24
    Vote Rating
    0
    uxdan is on a distinguished road

      0  

    Default


    that looks very promising, except i keep getting double output of what i decide to change. so if i do:

    Code:
    prepareData: function(data) {
     data.text = data.text + 'test';
     return data;
    }
    i will get my my string back with 'testtest' appended.

    Any ideas why it is doubled?

  6. #6
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,207
    Vote Rating
    858
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    try

    Code:
    prepareData: function(data) {
       data.text = 'test';
       return data;
    }
    What you were doing was taking what was in data.text and adding 'test' to it.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  7. #7
    Ext User
    Join Date
    Jul 2010
    Posts
    24
    Vote Rating
    0
    uxdan is on a distinguished road

      0  

    Default


    that just completely replaces data.text. (which works as expected) I don't want to do that. I want to append something to it. But it appends it twice.

  8. #8
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,207
    Vote Rating
    858
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Is it getting fired twice? Normally it should of course fire once. Are you loading it, refreshing, or filtering it?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  9. #9
    Ext User
    Join Date
    Jul 2010
    Posts
    24
    Vote Rating
    0
    uxdan is on a distinguished road

      0  

    Default


    Not to my knowledge... I doing a read on the store on initComponent. But that is it. Hehe... i have no idea what is going on.

    As I mentioned before, if I can do a simple replace, but for whatever reason any appending just doubles the appened value. It's not doubling the initial values.

    I'm wondering if it has something to do with that prepareData function.

  10. #10
    Ext User
    Join Date
    Mar 2007
    Posts
    94
    Vote Rating
    0
    danvega is on a distinguished road

      0  

    Default


    I decided to try this, but I am just looping over the results and updating the text. This works but I am seeing some really odd results. The regex doesn't seem to completely work, its wrapping more text than it should

    Code:
    	onRefresh: function(){
    		var twitterStore = Ext.getCmp('twitter-list').getStore();
    		
    		Ext.getBody().mask(false, '<div class="loading">Loading&hellip;</div>');
    		
    		Ext.util.JSONP.request({
                url: 'http://search.twitter.com/search.json',
                callbackKey: 'callback',
    			params:{
                    q: 'cfunited',
                    rpp: 50,
                    suppress_response_codes: true
    			},
                callback: function(result) {
    				var tweets = result.
    
    				for( var i=0; i < tweets.length; i++){
    					tweets[i].text = tweets[i].text.replace(/(http:\/\/)(.*)\s/gi, '<a href="$1$2">$1$2</a>');
    				}
    				
    				twitterStore.loadData(tweets);
    				Ext.getBody().unmask();	
                }
            });
    		
    	},

Similar Threads

  1. How do I create a a simple list of links?
    By kohalza in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 9 Aug 2012, 2:12 AM
  2. How to create links in templates?
    By Dumas in forum Ext 3.x: Help & Discussion
    Replies: 8
    Last Post: 19 Jul 2010, 6:38 AM
  3. Replies: 0
    Last Post: 15 Jul 2009, 12:46 AM
  4. howto create a tabpanel with links dynamically
    By Mario Minati in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 21 Jul 2008, 7:42 AM
  5. How to create menu items like the "Quick Links" above?
    By pnfsjp in forum Ext 1.x: Help & Discussion
    Replies: 0
    Last Post: 25 Sep 2007, 8:18 PM

Thread Participants: 3

Tags for this Thread