Nativescript-ngx-slides : Unable to go to next or previous slides - nativescript

I am unable to navigate to Next or Previous slides, using Nativescript--ngx-slides plugin.
Is this feature not enabled ? If yes, then how to call these methods ?
When I use,
#ViewChild("slides") slides: SlidesComponent
Then in
NgAfterViewInit let slidesComponent = <SlidesComponent>this.slides.nativeElement
I get an undefined error.
Any suggestions ?

I figured out, instead of ElementRef use SlidesComponent:
import { SlidesComponent } from "nativescript-ngx-slides";
...
and then
#ViewChild("slideContainer") slideContainer: SlidesComponent;
and then call the nextSlide() method:
onNextSlide() {
this.slideContainer.nextSlide();
}
Cheers

Related

UmbrellaException which contains ClassCastException when using GWTBootstrap3 Extras Summernote event handling (KeyUp Event)

I try to handle a Summernote Keyup event with this:
myEditor.addSummernoteKeyUpHandler(new SummernoteKeyUpHandler() {
#Override
public void onSummernoteKeyUp(final SummernoteKeyUpEvent event) {
// TODO Auto-generated method stub
log.fine("hello");
}
});
I get a UmbrellaException which is IMHO a class cast exception.
This is the call stack
I identified the following spot where te cast failes:
#HasNoSideEffects
static native boolean canCast(Object src, JavaScriptObject dstId) /*-{
if (#com.google.gwt.lang.Cast::instanceOfString(*)(src)) {
return !!#com.google.gwt.lang.Cast::stringCastMap[dstId];
} else if (src.#java.lang.Object::castableTypeMap) {
return !!src.#java.lang.Object::castableTypeMap[dstId]; //<-- this returns false!!!
} else if (#com.google.gwt.lang.Cast::instanceOfDouble(*)(src)) {
return !!#com.google.gwt.lang.Cast::doubleCastMap[dstId];
} else if (#com.google.gwt.lang.Cast::instanceOfBoolean(*)(src)) {
return !!#com.google.gwt.lang.Cast::booleanCastMap[dstId];
}
return false;
}-*/;
dstId contains:
Any help greatly appreciated!
I tested this with a small demo which actually works. But in my large application, I get this exception and I don't see why.
Do you have any idea whats wrong here?
Best regards
Hannes
As Andrei suggested I set the style to DETAILED. I use Eclipse as a development environment. I decided to clean build the system (which I had done before). Now the problem has simply vanished !! Furthermore, I use SDBG (see: https://sdbg.github.io/) to debug my GWT application. This works pretty well (even without -style DETAILED). Now the very very strange thing remains. I can set breakpoints for my application and they all work well, except setting a breakpoint within the event handling method. I use a logger to print some text to the console, so I see that the event handler for summernote is actually called but the debugger will not stop. I checked whether the breakpoint is listed in the tab "Breakpoints" and it is and it is checked. I don't get it. Perhaps I have to rebuild all again.
But to keep long things short:
The solution to the problem is probably to really issue a clean build and then hope for the best.

Mozilla reload API method doesn't work

I try to reload a Web page using (JavaXPCOM):
nsIWebBrowser webBrowser = (nsIWebBrowser) browser
.getWebBrowser();
nsIWebNavigation webNavigation = (nsIWebNavigation) webBrowser.queryInterface(nsIWebNavigation.NS_IWEBNAVIGATION_IID);
try {
nsISHistory sessionHistory = webNavigation.getSessionHistory();
if (sessionHistory != null) {
webNavigation = (nsIWebNavigation) sessionHistory.queryInterface(nsIWebNavigation.NS_IWEBNAVIGATION_IID);
}
} catch (XPCOMException e) {
}
webNavigation.reload(nsIWebNavigation.LOAD_FLAGS_NONE);
But reload doesn't happen at all. I tried force it by using the following flags, but page doesn't refresh as well:
nsIWebNavigation.LOAD_FLAGS_BYPASS_PROXY|nsIWebNavigation.LOAD_FLAGS_BYPASS_CACHE
Anyone knows what can be the reason for that?
Thanks!
Did you try checking Error Console for syntax errors? You seem to be trying to use C++ type casts in JavaScript. That cannot work. Assuming that browser is a <browser> element, this should work:
browser.reload();
Or:
browser.reloadWithFlags(Components.interfaces.nsIWebNavigation.LOAD_FLAGS_BYPASS_PROXY|Components.interfaces.nsIWebNavigation.LOAD_FLAGS_BYPASS_CACHE);
See https://developer.mozilla.org/en/XUL/browser for documentation on the <browser> element.
Edit: Given that this is apparently using JavaXPCOM the code seems to be correct with the exception that the entire try .. catch block should be removed. The only flag should be LOAD_FLAGS_BYPASS_CACHE to make sure you don't get a cached response.

jQuery .toggle(showOrHide): implementation question

I'm having a button toggle whether a referenced div is visible or not. Originally, I was using the code:
$('#search-options-btn').click(function() {
if ($('#search-options').is('.hidden')) {
$('#search-options').removeClass('hidden');
} else {
$('#search-options').addClass('hidden');
}
});
However, in an attempt to find cleaner code, I came across the jQuery toggle() method, which according to the API has a method implementation
.toggle( showOrHide )
showOrHide: A Boolean indicating whether to show or hide the elements.
This description leads me to believe this is a shortcut implementation method for showing or hiding by passing the...identifier? showOrHide into the toggle() method.
Of course, attempting this:
$('#search-options-btn').click(function() {
$('#search-options').toggle(showOrHide);
});
yields an error in my firebug console:
showOrHide is not defined
[Break On This Error] $('#search-options').toggle(showOrHide);
I've also tried defining showOrHide as a boolean initialized to false; the error goes away, but the issue is not fixed.
According to the jQuery online API, this is supposed to be equivalent to
if ( showOrHide == true ) {
$('#foo').show();
} else if ( showOrHide == false ) {
$('#foo').hide();
}
unless I'm completely missing how this works. Can anyone fill me in on what I'm doing wrong here? I haven't been able to find a similar implementation.
you should just need toggle(), nothing else.
$('#search-options-btn').click(function() {
$('#search-options').toggle();
});
showOrHide is the internal name. You pass in a bool:
$('#...').showOrHide(true)
if you want the item to be visible, false if you want it hidden.
Its just toggle between class and not with boolean..
$('#search-options-btn').click(function() { $('#search-options').toggle('yourClassName'); });
If yourClassName is found, then it will remove the same, otherwise it will add it.

Cant seem to get this plugin to respond to my termination of the setTimeout. Any help?

The test can be found here. I would like to be able to pass my plugin a new option string of 'false' and have my timer stop. http://www.jsfiddle.net/j78nk/2/
There is no element with the class gallery2 on that page, so pressing the button won't do anything.
Also, you are not checking the set options, only the defaults. And you return right away, before you do anything:
if (!defaults.running) {
return;
console.log('timer is inactive');
}
That code needs to be:
if (!options.running) {
console.log('timer is inactive');
return;
}

Returning value from AJAX request in a global variable

Sorry if this question is duplicated but I couldn't solve my problem from other solutions.
I've got this code in a sepate file included in my main index:
var getSuggestedData = {
serviceURL: $("input[name=suggestedServices]").val(),
dataR:"",
doRequest:function(){
//request data to controller
$.ajax({
url:this.serviceURL,
success:function(msg){
this.dataR = msg;
}
})
}
}
When I'm trying to get the variable "dataR" from my index this way it's UNDEFINED! PLEASE, can someone help me out?
$().ready(function() {
getSuggestedData.doRequest();
alert(getSuggestedData.dataR);
});
Thank you in advance!
The reason you are not able to access the dataR object is because it is not in the same context as the result returned from the success method.
One technique is to hold a reference to this in a variable as shown below:
var self = this;
using the jquery library!
$(this.button).bind('click',{self:this},function(event)
{
var that = event.data.self;
alert(that.num);
});
You can also check out the post below in which I explained in detailed about the "this" keyword.
http://azamsharp.com/Posts/57_I_mean__this__not__this_.aspx
If memory serves me right...
this.dataR = msg;
probably needs to be
getSuggestedData.dataR = msg
the 'this' reference would be to the object fed to jQuery, you need to reference the original object. I forget if you could access it by its name directly such as this or if you need to use another method, let me know if it doesn't work out though.

Resources