JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 20th, 2013, 10:53 AM
danjapro danjapro is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 193 danjapro Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 1 Day 4 h 21 m 37 sec
Reputation Power: 0
Exclamation jQuery - How to load() a template file, then pass it as a variable or do an alert test

I am using php, and need to load() this , template content php file into the jquery and pass it to a #div ID to render front-end view.


I am not sure how to load the php file in jquery and then pass it as a variable called repeater which helps build out all the rows combining the template loaded with Ajax (obj) query results.

In the set alert, it pops up as [object Object], no template.
When I write the entire php template content out into jquery as var repeater, it works, but I do not want all that html in jquery. Just load() then read.

Here is the code if this makes any sense
Code:
			   $('#pageContent').load('../includes/OrderLookup.php #pageContent');
				   alert ($('#pageContent').load('OrderLookup.html #pageContent'));
				   var url = $('#pageContent').load('../includes/OrderLookup.php');
				   var page = '<div id="pageContent"></div>';
	               var repeater = $('#pageContent').load('OrderLookup.html #pageContent');
				   
					     
				   
				   var pageBuildUp='';
                    for (x in dataArray){
                         pageBuildUp += obj.repeater;
					    //alert(obj.repeater);
						//pageBuildUp += url;
                        pageBuildUp = pageBuildUp.replace('##transactionId##',makeTextSmall(dataArray[x]['blockvalue'],20));
                        if (dataArray[x]['description']==''){
                            pageBuildUp = pageBuildUp.replace('##orderTotal##','no total amount');
                        }

Reply With Quote
  #2  
Old February 21st, 2013, 12:00 PM
danjapro danjapro is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 193 danjapro Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 1 Day 4 h 21 m 37 sec
Reputation Power: 0
How would I like to know can this work, for what I'm trying to accomplish:

Code:

 var url = $('#pageContent').load('/includes/OrderLookup.php');
				   var page = '<div id="pageContent"></div>';
	               //var repeater = $('#pageContent').load('OrderLookup.html #pageContent');
				   

					$('#pageContent').load("includes/OrderLookup.php", function(dataRow) {
					  alert("Data Loaded: " + dataRow);
					  var repeater = dataRow;
					});
				   
				   
                   // var items = $(dataArray).find('blockvalue');
					// $(items).each(function(i)
				    // {
						  // resultStr += $(this).text() + '<br />';
						  // $('#ub_block_results').html(resultStr);
				    // });
					//end of each
				     
				   
				   var pageBuildUp='';
                    for (x in dataArray){ 
                         pageBuildUp += obj.repeater;
						//pageBuildUp += obj.repeater;
					    //alert(obj.repeater);
						//pageBuildUp += url;
                        pageBuildUp = pageBuildUp.replace('##transactionId##',makeTextSmall(dataArray[x]['blockvalue'],20));
                        if (dataArray[x]['description']==''){
                            pageBuildUp = pageBuildUp.replace('##orderTotal##','no total amount');
                        }
			   

Reply With Quote
  #3  
Old February 21st, 2013, 12:39 PM
danjapro danjapro is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 193 danjapro Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 1 Day 4 h 21 m 37 sec
Reputation Power: 0
Exclamation how to load() template into div in jquery and pass on

I changed my code some. Using function(dataRow), I can gather the Temlate file.
But problem now is the function cannot be inside of the Main function and work properly.

How to wrap that function with my current loop pagebuildup function?

Code:

$.post("ajax/search_full_block.php",{query:searchQuery,limit:limiter,accountID:accountID,blocktype:block_type,emailID:emailID},function  (dataReturn){
var obj = jQuery.parseJSON(dataReturn);
alert('---success---');
if (obj.Ack=="success"){


$('#resultsset').html('');
var dataArray = obj.data;
var totalCount = obj.total_count;
var optionsBloc='';



var repeater = $('#pageContent').load('includes/OrderLookup.php');
alert($("#pageContent").html(repeater));
var page = '<div id="pageContent"></div>';



$('#pageContent').load("includes/OrderLookup.php", function(dataRow) {
alert("Data Loaded: " + dataRow);
var repeater = dataRow;
});



var pageBuildUp='';
for (x in dataArray){
pageBuildUp += obj.repeater;
pageBuildUp = pageBuildUp.replace('##transactionId##',makeTextSmall(dataArray[x]['blockvalue'],20));
if (dataArray[x]['description']==''){
pageBuildUp = pageBuildUp.replace('##orderTotal##','no total amount');
}


Reply With Quote
  #4  
Old February 22nd, 2013, 02:03 PM
danjapro danjapro is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 193 danjapro Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 1 Day 4 h 21 m 37 sec
Reputation Power: 0
I am trying to get the template to load into a div or just to display the contents of that template file:

Code:
var repeater = $('#pageContent').load('includes/OrderLookup.php');


that does not seem to work when I set it as a var

however, this is the template written into the jquery and it works well. But I do not want to load the template in the jQuery:
Code:
				   var repeater = '<div class="ub-quick-results-box" id="OrderLookupResults"  onclick="showEditBlock(##Orderid##);" style="border-top-left-radius: 5px; border-top-right-radius: 5px; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; background-color: rgb(250, 250, 250); "><div class="repeater_blockname" id="transactionId" style="font-size:12px; font-family:arial; color:#787878;border-right:solid 1px #ebebeb; width: 220px; display: inline-block; padding-left: 35px; height: 20px; padding-top: 0px; cursor: pointer; "> <a href="#" onclick="showinfobox(##transactionId##);">##transactionId## </a> </div><div class="repeater_blockname" id="orderDate" style="font-size:12px; font-family:arial; color:#787878;border-right:solid 1px #ebebeb; width: 120px; display: inline-block; padding-left: 35px; height: 20px; padding-top: 0px; "> ##orderDate## </div><div class="repeater_blockname" id="orderTotal" style="font-size:12px; font-family:arial; color:#787878;border-right:solid 1px #ebebeb; width: 220px; display: inline-block; padding-left: 45px; height: 20px; padding-top: 0px; font-weight: bold; "> <span>##orderTotal## </span> </div><div class="repeater_blockname" onclick="actdeBlock(##Orderid##)" id="status" style="font-size:14px; font-family:arial; color:###colour##;border-right:solid 0px #ebebeb; width: 120px; display: inline-block; padding-left: 20px;  padding-top: 0px; "  > <span id="ub_block_status_display_##Orderid##" style="color:###colour##">##status##</span> </div><input type="hidden" id="ub_hidden_status_##Orderid##" value="##status_val##"/></div>';
					


How to load(), to return just the empty template into var and pass it to my pagebuildup.

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > jQuery - How to load() a template file, then pass it as a variable or do an alert test

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap