GetCmp() is not working in sencha - sencha-touch

i'm using getCmp('componentid').hide();
its not working.
if (flag_in == 1) {
console.log('inside if of hide');
Ext.getCmp('inboxQueueId').hide();
var el = btn.el;
Ext.getCmp('inbox_hide').setIconCls('show');
flag_in = 0;
Ext.getCmp('queueViewPanel').setWidth('100%');
} else {
console.log('inside else of hide');
Ext.getCmp('inboxQueueId').show();
var element = btn.element;
Ext.getCmp('inbox_hide').setIconCls('hide');
flag_in = 1;
Ext.getCmp('queueViewPanel').setWidth('70%');
}
its coming inside if but Ext.getCmp('inboxQueueId').hide() is not working.
And its not giving error.
Please help me.

Try this,
Ext.getCmp('inboxQueueId').hide('slide', false)
Or something like this,
Ext.getCmp('inboxQueueId').hide(false)
I hope this helps. :)

Related

results.row[i] is undefined using react-native-db-models

Im new to React Native and Im using react-native-db-models. I have searched stackoverflow for fetching the data and it gave me this code below
DB.users.get_all((result) => {
let data = [];
for (let i = 1; i <= result.totalrows; i++) {
data.push(result.rows[i]);
}
but result.rows[i] returns undefined. Any ideas how and why?
I tried my own solution but this time it gave me another problem. This is my code
DB.expense.get_all(function(result){
var data = [];
for (let i = 1; i <= result.totalrows; i++) {
let j = result.autoinc;
let id = j - i;
DB.expense.get_id(id, function(results){
data.push(result)
})
}
}
when I put console.log(data) after data.push(result) it works fine. But when I put console.log(data) outside DB.expense.get_id function, console.log(data) returns an empty array.
I really need your help guys

function + module.exports

I have a problem with module.export on titanium. I tried following https://wiki.appcelerator.org/display/guides/CommonJS+Modules+in+Titanium but it doesn't work at all.
I have 2 little pieces of code. App.js:
var fenetreBase = Titanium.UI.createWindow({fullscreen:true,backgroundColor:"white",exitOnClose:true});
fenetreBase.open();
var vueimage = new (require('UI/viewimage'))();
vueimage.test();
fenetreBase.add(vueimage);
and viewimage.js in the folder UI.
function viewimage() {
var lavue = Ti.UI.createView({backgroundColor:'red' });
var item =...
lavue.add(item...);
return lavue;
}
viewimage.prototype.test = function() {
Ti.API.info("test");
};
module.exports = viewimage;
I have an error saying
Object #<view> has no method 'test' in app.js vueimage.test()
In my mind, I follow the example of "Instantiable Objects" in the wiki above but I may have not understand something. I expect I made a stupid mistake. I tried many other things, each uglier than other and it doesn't work anyway.
Can somebody tell me where the mistake is?
your mistake is assuming that you have an instance of viewimage when you run:
var vueimage = new (require('UI/viewimage'))();
you are getting an instance of
var lavue = Ti.UI.createView({backgroundColor:'red' });
which doesn't have a test property.
Perhaps you could use an object like this instead:
function viewimage() {
var result = {};
var lavue = Ti.UI.createView({backgroundColor:'red' });
var item =...
lavue.add(item...);
result.lavue = lavue;
result.test = function() {
Ti.API.info("test");
};
return result;
}
EDIT
In your App.js:
var vueimage = new (require('UI/viewimage'))();
vueimage.test();
fenetreBase.add(vueimage.lavue);

swipe.js getPos API help needed

I'm using for a mobile solution the slider "swipe.js" (https://github.com/bradbirdsall/Swipe). Now i would like to use the api-function getPos to return the actually slide. Unfortunatley my code doesn't work:
var elem = document.getElementById('mySwipe');
window.mySwipe = Swipe(elem, {
callback: function() {
var pageNumber = elem.getPos();
alert("P"+pageNumber);
}
});
What's wrong? how doest it work?
thanks for your help
You were almost there:
var pos = mySwipe.getPos() + 1;
alert( pos );

Mootools variable scope issues

I have a problem getting my mind round variable scope and could do with some help :)
I'm setting up a module in joomla that will rotate images. I've a bit of code I've used on non Joomla sites that works fine. However I've ported it and I'm running into problems that I think are variable scope issues so any thoughts would be great.
Sorry for the long code but I included the whole function in case (when it works) it might help someone else.
function slideshow(container,containerCaption,previewCode,timer,classis,headerId,thumbOpacity,titlebar){
var showDuration = timer;
var container = $(container);
var images = $(container).getElements('span');
var currentIndex = 0;
var interval;
var preview = new Element('div',{
id: containerCaption,
styles: {
opacity: thumbOpacity
}
}).inject(container);
preview.set('html',previewCode);
images.each(function(img,i){
if(i > 0) {
img.set('opacity',0);
}
});
var show = function() {
images[currentIndex].fade('out');
images[currentIndex = currentIndex < images.length - 1 ? currentIndex+1 : 0].fade('in');
var title = '';
var captionText = '';
if(images[currentIndex].get('alt')) {
cap = images[currentIndex].get('alt').split('::');
title = cap[0];
captionText = cap[1];
urltoUse = cap[2];
preview.set('html','<span class="lctf1"><ahref="'+urltoUse+'">'
+ title + '</a></span>'
+ (captionText ? '<p>' + captionText + '</p>' : ''));
}
};
window.addEvent('domready',function(){
interval = show.periodical(showDuration);
});
}
window.addEvent('domready',function() {
container = "slideshow-container";
containerCaption ="slideshow-container-caption";
previewCode = '<span ><?php echo $itemtitle[0];?></span><p ><?php echo $itemdesc[0];?></p>';
timer = <?php echo $slidetime*1000;?>;
classis = 1;
headerId = "";
thumbOpacity =0.7;
titlebar = "<?php echo $showTitle;?>";
if($(container)){
slideshow(container,containerCaption,previewCode,timer,classis,headerId,thumbOpacity,titlebar);
}
});
The javascript error being thrown is that preview is undefined.
Your code seems to work, I made a jsfiddle here: http://jsfiddle.net/7E2MX/3/ which runs with no errors.
I did change one line though:
var images = $(container).getElements('span');
to
var images = $(container).getElements('img');

CodeIgniter - Changing normal SQL into CI's own language

Can someone show me how to change the following SQL into CI's active stuff.
$query = $this->db->query('UPDATE pollanswers SET pollAnswerPoints = pollAnswerPoints + 1 WHERE pollAnswerID = '.$pollanswerid.'');
return true;
Also, how would i add an if statement to that to see if it completed properly return true, if not return false?
Cheers,
try this
$this->db->set('pollAnswerPoints', 'pollAnswerPoints + 1', FALSE);
$this->db->where('pollAnswerID', $pollanswerid);
$this->db->update('pollanswers');
Edit:
if($this->db->affected_rows() > 0)
{
return true;
} else
{
return false;
}