In Html5:- in footer it will store the data which is cuming dynamically and footer part should move by touch not whole window only footer should move with the data is present in footer left to right
<div data-role="page" id="page1">
<div data-role="footer" data-position="fixed" id="footer">
<div class="menu" id="menu_button1" id="scroll_menu" onmouseover='this.style["overflowX"]="scroll";' onmouseout='this.style["overflowX"]="visible";'></div>
</div>
</div>
In Jquery:- I am using Ajax calling to get the data dynamically in stored that data in footer part of Htm5 in there i want to use touch event how i can use plz help me out
function callMenuConnection() {
$.support.cors = true;
$.ajax({
type: "POST",
url: "one.html",
contentType: "text/xml",
dataType: "xml",
data: "",
cache:false,
processData:false,
crossDomain:true,
success: processSuccess,
error: processError
});
}
function processSuccess(data) {
$(data).find("category").each(function () {
var id = $(this).find('id').text();
var title = $(this).find('title').text();
var scripts = "<a href='#' data-role='button' data-theme='b' data-inline='true'>"+title+"</a>"
$("#menu_button1").append(scripts).trigger('create');
});
}
function processError(data)
{
alert("error");
}
$(document).unbind('pageinit').bind('pageinit', function () {
callMenuConnection();
});
Finally i got the answer of these
In HTML5:-
<div data-role="page" data-theme="b" id="jqm-home">
<div data-role="footer" data-position="fixed" data-theme="c">
<div class="categories" id="cat">
<ul id="cat_list" class="cat_list_class"></ul>
</div>
</div>
</div>
In jquery:-
var step = 1;
var current = 0;
var maximum = 0;
var visible = 2;
var speed = 500;
var liSize = 120;
var height = 60;
var ulSize = liSize * maximum;
var divSize = liSize * visible;
$(document).unbind('pageinit').bind('pageinit', function () {
callMenuConnection();
$('.categories').css("width", "auto").css("height", height+"px").css("visibility", "visible").css("overflow", "hidden").css("position", "relative");
$(".categories ul a").css("list-style","none").css("display","inline");
$(".categories ul").css("width", ulSize+"px").css("left", -(current * liSize)).css("position", "absolute").css("white-space","nowrap").css("margin","0px").css("padding","5px");
});
$(document).unbind('click').bind('click', function () {
scroll();
});
function callMenuConnection() {
$.support.cors = true;
$.ajax({
type: "GET",
url: "one.html",
contentType: "text/xml",
dataType: "xml",
data: "",
cache:false,
processData:false,
crossDomain:true,
success: processSuccess,
error: processError
});
}
var scripts ="";
function processSuccess(data) {
$(data).find("category").each(function () {
var id = $(this).find('id').text();
var title = $(this).find('title').text();
scripts = scripts+'<a class="ids_cat" data-role="button" data-transition="slide" data-inline="true" >' +title+ '</a>';
});
$('#cat_list').append(scripts);
$('#cat_list').trigger('create');
maximum = $(".categories ul a").size();
}
function processError(data)
{
alert("error");
}
function scroll(){
$(".categories").swipeleft(function(event){
if(current + step < 0 || current + step > maximum - visible) {return; }
else {
current = current + step;
$('.categories ul').animate({left: -(liSize * current)}, speed, null);
}
return false;
});
$(".categories").swiperight(function(event){
if(current - step < 0 || current - step > maximum - visible) {return; }
else {
current = current - step;
$('.categories ul').animate({left: -(liSize * current)}, speed, null);
}
return false;
});
}
Please use swipe event on the footer selector. Something like :
// Temp Id Card back page swipe event
$("#FooterId").on('swipe', function (e) {
// keep changing the data here in some div, it would give illusion that footer is changing...
});
Related
I have a problem about how to get a response from another website using php (api.php) but it works if api.php is placed in my folder where ( Index.php ) is also. Is it possible to get the responses from other pages like ( myurl.com/api.php ). Sorry for my bad english.
ajax placed from index.php
<script title="ajax do checker">
function enviar() {
var linha = $("#lista").val();
var linhaenviar = linha.split("\n");
var total = linhaenviar.length;
var ap = 0;
var rp = 0;
linhaenviar.forEach(function(value, index) {
setTimeout(
function() {
$.ajax({
url: 'api.php?lista=' + value,
type: 'GET',
async: true,
success: function(resultado) {
if (resultado.match("#Aprovada")) {
removelinha();
ap++;
aprovadas(resultado + "");
}else {
removelinha();
rp++;
reprovadas(resultado + "");
}
$('#carregadas').html(total);
var fila = parseInt(ap) + parseInt(rp);
$('#cLive').html(ap);
$('#cDie').html(rp);
$('#total').html(fila);
$('#cLive2').html(ap);
$('#cDie2').html(rp);
}
});
}, 500 * index);
});
}
function aprovadas(str) {
$(".aprovadas").append(str + "<br>");
}
function reprovadas(str) {
$(".reprovadas").append(str + "<br>");
}
function removelinha() {
var lines = $("#lista").val().split('\n');
lines.splice(0, 1);
$("#lista").val(lines.join("\n"));
}
code where the response will appear
<h6 style="font-weight: bold;" class="card-title">Declined - <span id="cDie2" class="badge badge-danger">0</span></h6>
<div id="bode2"><span id=".reprovadas" class="reprovadas"></span>
api.php
enter link description here
full code for index.php enter link description here
I wanted reload a core-list element to show new data, but it´s not refreshing.
I re-call the JS function thats generate the data but doesn t work... and reload like a 'normal' div doesn t work either! The list only shows the new data if i reload the entire page...
function values(sender, textomsg, datacriacao, senderfoto){
var sender2 = sender.split(",");
var textomsg2 = textomsg.split(",");
var datacriacao2 = datacriacao.split(",");
var senderfoto2 = senderfoto.split(",");
var namegen = {
generateString: function (inLength) {
var s = '';
for (var i = 0; i < inLength; i++) {
s += String.fromCharCode(Math.floor(Math.random() * 26) + 97);
}
return s;
},
generateName: function (inMin, inMax) {
return this.generateString(Math.floor(Math.random() * (inMax - inMin + 1) + inMin));
}
};
Polymer('list-test', {
count: sender.length,
ready: function () {
this.data = this.generateData();
},
generateData: function () {
var names = [], data = [];
for (var i = 0; i < this.count; i++) {
names.push(namegen.generateName(4, 8));
}
names.sort();
for (var i = 0; i < this.count; i++) {
data.push({
index: i,
sender: sender2[i],
textomsg: textomsg2[i],
datacriacao: datacriacao2[i],
senderfoto: senderfoto2[i]
});
}
return data;
},
tapAction: function (e) {
console.log('tap', e);
}
});
}
<%----%>
<template id="templateConversas" runat="server">
<div id="item" class="item {{ {selected: selected} | tokenList }}" ><%--onClick="conversa('{{name}}');"--%>
<div class="message" style="background-image: url({{senderfoto}});">
<span class="from"><br/>{{sender}}</span>
<span class="timestamp">{{datacriacao}}</span>
<div class="subject"><br/>{{textomsg}} </div><%--------Infinite List. {{index}}--%>
<%--<div class="body"><br/>Mensagem de teste...........</div>--%>
</div>
</div>
</template>
The problem is also reload the 'list-test'. if i call the js function after the list is loaded it doesn't apply the new data...
Your code isn't complete so it is hard to understand but I think that the problem is that you don't assign the result of the generateData() function to the template's model. Try following script for your component
Polymer('list-test', {
created: function () {
this.data = [];
},
refresh: function () {
this.data = this.generateData();
},
generateData: function () {
// your original code here
}
});
Now the list content should be updated with newly generated data when you call refresh() of the list-test element. To fill the list when element is created add
ready: function () {
this.refresh();
},
I am trying to append the content dynamically when i swipe the page i try the following method
JS part:
var i = 2;
$(document).on('pagebeforeshow ', function () {
loadPage(i);
});
function loadPage(index) {
$.ajax({
url: "connection.php",
type: "POST",
datatype: 'json',
data: {
"pageIndex": index
},
beforeSend: function (a, b) {
$.mobile.showPageLoadingMsg();
},
success: function (result) {
var a = $.parseJSON(result);
$('.primarycontent').append('<img src="images/' + a.report + '" />');
$.each(a.controls, function (j, row) {
if (row.controltype == "dropdown") {
var selectarray = row.controlvalues.split(",");
addDropDown(selectarray, j);
}
if (row.controltype == "button") {
var urlvalue = row.controlvalues;
addButton(urlvalue, j);
}
});
},
complete: function () {
$.mobile.hidePageLoadingMsg();
},
error: function (request, error) {
alert('Network error has occurred please try again!');
}
});
var dropdown_array = [];
function addDropDown(values, count) {
var selectElm = $("<select/>");
selectElm.attr({
'name': 'dropdown-' + count,
'id': 'dropdown-' + count
}).appendTo('#dropdownplace');
dropdown_array.push('dropdown-' + count);
$.each(values, function (a, b) {
selectElm.append($("<option/>").attr("value", b).text(b)).appendTo('#dropdown-' + count);
});
$('select').selectmenu();
return;
}
function addButton(url, count) {
for (m = 0; m < dropdown_array.length; m++) {
var selected_dropdown = $("#" + dropdown_array[m]);
// alert(selected_dropdown.val());
}
$('#buttonPlaceHolder').append('Refresh');
// refresh jQM controls
$('#home2').trigger('create');
//myselect[0].selectedIndex = 3;
//var button = $("<a/>");
//button.attr({'href':url+});
return;
}
}
$(document).off('swipeleft').on('swipeleft', 'div[data-role="page"]', function (event) {
if (event.handled !== true) // This will prevent event triggering more then once
{
alert(hi);
var nextpage = $.mobile.activePage.next('div[data-role="page"]');
// swipe using id of next page if exists
if (nextpage.length > 0) {
alert(hi);
i++;
$.mobile.changePage(nextpage, {
transition: "slide",
reverse: false
}, true, true);
loadPage(i++);
}
event.handled = true;
}
return false;
});
$(document).off('swiperight').on('swiperight', 'div[data-role="page"]', function (event) {
if (event.handled !== true) // This will prevent event triggering more then once
{
var prevpage = $(this).prev('article[data-role="page"]');
if (prevpage.length > 0) {
$.mobile.changePage(prevpage, {
transition: "slide",
reverse: true
}, true, true);
}
event.handled = true;
}
return false;
});
index.html:
<div data-role="page" id="home2">
<!-- Header -->
<div data-role="header" class="header1" data-theme="b">
<h1>Group:Group Name</h1>
<a data-role="button" data-rel="back" data-icon="arrow-l">Search</a>
</div>
<!-- Content -->
<div data-role="content">
<div>
<div id="dropdownplace"></div>
<div id="buttonPlaceHolder"></div>
<div class="primarycontent"></div>
</div>
</div>
<!-- Footer -->
<div data-role="footer" data-id="persistantFooter" data-position="fixed" class="nav-glyphish-example">
<div data-role="navbar" class="nav-glyphish-example" data-grid="c">
<ul>
<li>Home
</li>
<li>Feeds
</li>
<li>Secure
</li>
<li>Contacts
</li>
</ul>
</div>
</div>
</div>
now i want to append the content when i swipe left or right i send the index value to my connection.php.I want to like this demo from this link
Thanks
Suppose in footer part i want 50 data which is coming through ajax call and all data should be in straight line when we touch the data it will also move and through mouse also it will also move like it should scroll plz help me out i m getting data but it is not scrolling and data is not coming in straight line
thanks in advance
In HTML5:-
<div data-role="footer" data-position="fixed" id="footer_ids" onmousedown="startReverseSlider(event)" ontouchstart="startReverseSlider(event)">
<div class="menu_cat_ids" id="menu_button_ids" ></div>
</div>
<style>
#footer_ids{
position: fixed;
width:100%;
overflow-x:auto;
bottom: 1px;
z-index: 10;
text-align: center;
height: 5%;
}
</style>
in jquery:-
$(document).unbind('pageinit').bind('pageinit', function () {
callMenuConnection();
});
function callMenuConnection() {
$.support.cors = true;
$.ajax({
type: "GET",
url: "one.html",
contentType: "text/xml",
dataType: "xml",
data: "",
cache:false,
processData:false,
crossDomain:true,
success: function (data) {
$(data).find("category").each(function () {
var id = $(this).find('id').text();
var title = $(this).find('title').text();
var scripts = "<a href='#' data-role='button' data-theme='b' data-inline='true'>"+title+"</a>"
$("#menu_button_ids").append(scripts).trigger('create');
});
}
});
}
function startReverseSlider(event){
theElement=event.currentTarget;
startX = endX = getCurrentPositionX(event);
startY = endY = getCurrentPositionY(event);
mx = getCurrentPositionX(event) - $('#menu_button_ids').offset().left;
document.addEventListener("mousemove",moveReverseSlider,true);
document.addEventListener("mouseup",dropReverseSlider,true);
document.addEventListener("touchmove",moveReverseSlider,true);
document.addEventListener("touchend",dropReverseSlider,true);
//event.stopPropagation();
event.preventDefault();
}
function dropReverseSlider(event)
{
document.removeEventListener("mouseup",dropReverseSlider,true);
document.removeEventListener("mousemove",moveReverseSlider,true);
document.removeEventListener("touchend",dropReverseSlider,true);
document.removeEventListener("touchmove",moveReverseSlider,true);
//event.stopPropagation();
}
function moveReverseSlider(event)
{
endX = getCurrentPositionX(event);
endY = getCurrentPositionY(event);
var clientX = getCurrentPositionX(event) - mx;
if(clientX+sliderLeft < -w+vx-sliderLeft){
} else if (clientX > sliderLeft) {
} else {
$('#menu_button_ids').css('left',(clientX-sliderLeft)+'px');
var X =$('#menu_button_ids').offset().left - sliderLeft;
var P=-X*(rs)/(w);
if (P > rs-ts) {
P = rs - ts;
}
}
}
In HTML 5:
<div data-role="page" data-theme="b" id="jqm-home">
<div data-role="footer" data-position="fixed" data-theme="c">
<div class="categories" id="cat">
<ul id="cat_list" class="cat_list_class"></ul>
</div>
</div>
</div>
Now In JQuery:
var step = 1;
var current = 0;
var maximum = 0;
var visible = 2;
var speed = 500;
var liSize = 120;
var height = 60;
var ulSize = liSize * maximum;
var divSize = liSize * visible;
$(document).unbind('pageinit').bind('pageinit', function () {
callMenuConnection();
$('.categories').css("width", "auto").css("height", height+"px").css("visibility", "visible").css("overflow", "hidden").css("position", "relative");
$(".categories ul a").css("list-style","none").css("display","inline");
$(".categories ul").css("width", ulSize+"px").css("left", -(current * liSize)).css("position", "absolute").css("white-space","nowrap").css("margin","0px").css("padding","5px");
});
$(document).unbind('click').bind('click', function () {
scroll();
});
function callMenuConnection() {
$.support.cors = true;
$.ajax({
type: "GET",
url: "one.html",
contentType: "text/xml",
dataType: "xml",
data: "",
cache:false,
processData:false,
crossDomain:true,
success: processSuccess,
error: processError
});
}
var scripts ="";
function processSuccess(data) {
$(data).find("category").each(function () {
var id = $(this).find('id').text();
var title = $(this).find('title').text();
scripts = scripts+'<a class="ids_cat" data-role="button" data-transition="slide" data-inline="true" >' +title+ '</a>';
});
$('#cat_list').append(scripts);
$('#cat_list').trigger('create');
maximum = $(".categories ul a").size();
}
function processError(data)
{
alert("error");
}
function scroll(){
$(".categories").swipeleft(function(event){
if(current + step < 0 || current + step > maximum - visible) {return; }
else {
current = current + step;
$('.categories ul').animate({left: -(liSize * current)}, speed, null);
}
return false;
});
$(".categories").swiperight(function(event){
if(current - step < 0 || current - step > maximum - visible) {return; }
else {
current = current - step;
$('.categories ul').animate({left: -(liSize * current)}, speed, null);
}
return false;
});
}
i have to use scroll function in footer in which data is been stored in button dynamically and that scroll should hide then we scroll it show again and all data and scroll should be dynamically load in footer only window screen should not change only footer will change at time of scroll
in jquery:-
function callXMLConnection() {
$.support.cors = true;
$.ajax({
type: "GET",
url: "url.html",
contentType: "text/xml",
dataType: "xml",
data: "",
cache:false,
processData:false,
crossDomain:true,
success: processSuccess,
});
}
function processSuccess(data) {
$(data).find("category").each(function () {
var id = $(this).find('id').text();
var title = $(this).find('title').text();
var scripts = "<a href='#' data-role='button' data-theme='b' data-inline='true'>"+title+"</a>"
$("#menu_button1")
.append(scripts)
.trigger('create');
});
}
$(document).unbind('ready').bind('ready', function () {
$("#menu_button1").scroll(function () {
// if ($("#menu_button1").scrollLeft(300) == $(document).width() - $("#menu_button1").width())
if ($("#menu_button1").scrollHeight - $("#menu_button1").scrollTop() == $("#menu_button1").outerHeight())
{
callXMLConnection();
}
});
});
in html5:-
<div data-role="footer" data-position="fixed" id="scroll_menu" style="overflow: scroll;">
<div class="menu" id="menu_button1" ></div>
</div>
Finally i got the answer of these
In HTML5:-
<div data-role="page" data-theme="b" id="jqm-home">
<div data-role="footer" data-position="fixed" data-theme="c">
<div class="categories" id="cat">
<ul id="cat_list" class="cat_list_class"></ul>
</div>
</div>
</div>
In jquery:-
var step = 1;
var current = 0;
var maximum = 0;
var visible = 2;
var speed = 500;
var liSize = 120;
var height = 60;
var ulSize = liSize * maximum;
var divSize = liSize * visible;
$(document).unbind('pageinit').bind('pageinit', function () {
callMenuConnection();
$('.categories').css("width", "auto").css("height", height+"px").css("visibility", "visible").css("overflow", "hidden").css("position", "relative");
$(".categories ul a").css("list-style","none").css("display","inline");
$(".categories ul").css("width", ulSize+"px").css("left", -(current * liSize)).css("position", "absolute").css("white-space","nowrap").css("margin","0px").css("padding","5px");
});
$(document).unbind('click').bind('click', function () {
scroll();
});
function callMenuConnection() {
$.support.cors = true;
$.ajax({
type: "GET",
url: "one.html",
contentType: "text/xml",
dataType: "xml",
data: "",
cache:false,
processData:false,
crossDomain:true,
success: processSuccess,
error: processError
});
}
var scripts ="";
function processSuccess(data) {
$(data).find("category").each(function () {
var id = $(this).find('id').text();
var title = $(this).find('title').text();
scripts = scripts+'<a class="ids_cat" data-role="button" data-transition="slide" data-inline="true" >' +title+ '</a>';
});
$('#cat_list').append(scripts);
$('#cat_list').trigger('create');
maximum = $(".categories ul a").size();
}
function processError(data)
{
alert("error");
}
function scroll(){
$(".categories").swipeleft(function(event){
if(current + step < 0 || current + step > maximum - visible) {return; }
else {
current = current + step;
$('.categories ul').animate({left: -(liSize * current)}, speed, null);
}
return false;
});
$(".categories").swiperight(function(event){
if(current - step < 0 || current - step > maximum - visible) {return; }
else {
current = current - step;
$('.categories ul').animate({left: -(liSize * current)}, speed, null);
}
return false;
});
}