I code all my project in Alloy, so no classic Titanium here.
I want to load an external custom AlertDialog (located in views/popup.xml) in my index. So my need is to show an alert and destroy it (for ie.) by clicking the OK button. The Help button should do another action.
My popup.xml file :
<Alloy>
<AlertDialog id="popup" title="Error popup"
message="There is an error" cancel="1">
<ButtonNames>
<ButtonName>OK</ButtonName>
<ButtonName>Help</ButtonName>
</ButtonNames>
</AlertDialog>
</Alloy>
My index.js file :
function openPopup(e) {
var page = Alloy.createController('views/popup').getView();
page.show();
};
openPopup();
But this gives me an error :
[DEBUG] [iphone, 8.1, 192.168.0.1] Native
module:alloy/controllers/views/popup
[ERROR] [iphone, 8.1, 192.168.0.1] Couldn't find module:
alloy/controllers/views/popup
[ERROR] [iphone, 8.1, 192.168.0.1] TypeError: 'undefined' is not a
constructor (evaluating 'new (__p.require("alloy/controllers/" +
name))(args)')
I have no popup.js and I didn't require any file in index.js too. So my questions are : How to load a controller dynamically? How to remove (or destroy) it with an addEventListener on "click" action? Thank you.
Agree with turtle. When you create a controller it implicitly knows you are referring to a view in the the app/views directory.
And you should improve your code slightly by not creating a local variable (for garbage collection purposes). So instead of:
var page = Alloy.createController('views/popup').getView();
page.show();
You should just do:
Alloy.createController('views/popup').getView().open();
You can find more info about this in a splendid article by Fokke Zandbergen.
/John
Related
I created some custom shortcodes for my PrestaShop by creating a file (override/classes/controller/FrontController.php) with a method like :
public static function parseCMSContent($content)
{
...
}
And in my module and cms smarty templates I changed:
{$cms.content nofilter}
to:
{FrontController::parseCMSContent($cms.content) nofilter}
Everything was working fine with Prestashop 1.7.7.5, but the update to 1.7.8.2 broke the whole thing.
I get a 500 error saying :
PHP Fatal error: Uncaught Error: Call to undefined method FrontController::parseCMSContent() ... .module.pscustomtextpscustomtext. ...
It's still working fine with debug mode enabled though..
I can't find anything about the function being deprecated, any idea on how I could get this working again please?
In case this can help anyone, I fixed this by moving my override into a new smarty plugin.
I created a file vendor/smarty/smarty/libs/plugins/function.get_shortcoded_content.php
I added my shortcodes in:
function smarty_function_get_shortcoded_content($params, &$smarty)
{
...
}
And in my smarty files I called:
{get_shortcoded_content content=$cms.content}
instead of:
{$cms.content nofilter}
It seems to work all fine again.
I got a strange warning from Firebase Analytics today. It is:
<Warning> [Firebase/Analytics][I-ACS031011] Root view controller not found
The methods I am using is basically deleting a post and then displaying a status bar notification to the user that the post is deleted. This is the method that is called when we want to delete a post.
HomeViewNetwork.deletePost(postBlock: self.postDataBlock, handler: {
AlertManager.showStatusRed(title: "Post deleted!")
})
And my displaying status function is:
class func showStatusRed(title: String) {
let statusMessage = MessageView.viewFromNib(layout: .StatusLine)
var config = SwiftMessages.defaultConfig
config.presentationContext = .window(windowLevel: UIWindowLevelStatusBar)
statusMessage.configureContent(body: title)
statusMessage.backgroundView.backgroundColor = UIColor(red:0.98, green:0.11, blue:0.35, alpha:1.00)
setUpStatusView(messageView: statusMessage)
statusSwiftMessages.show(config: config, view: statusMessage)
}
The warning goes away if I comment the AlertManager.showStatusRed method. Also I am using SwiftMessages as my library for displaying the status bar notification.
I am not sure why Firebase is giving me this warning when Xcode is not giving any issues about root view controller. Any help is appreciated.
Related question for objective-C only project complied with Xcode 9 GM using FirebaseCore 4.0.4 (podfile.lock): Xcode 9 <Warning> [Firebase/Analytics][I-ACS031011] Root view controller not found
Updating the firebase and other related dependencies to latest version fixed the issue on my project.
- Firebase/Core (4.2.0):
- FirebaseAnalytics (= 4.0.3)
- FirebaseCore (= 4.0.7)
Answer on other thread: https://stackoverflow.com/a/46333312/342794
I'm trying to set up some test cases for a view using the Jasmine 2.3.4 assertion library for my Sencha Touch 2.4 app. Things seem great (I see the view rendered to a div) except the browser does not know what MyApp.app is. I have this line at my onContainerInitialize function from my view/container code:
var controller = MyApp.app.getController('loginController');
which gives this Jasmine error:
TypeError: Cannot read property 'getController' of undefined
At the time the Jasmine tests are called, from my console I do have a MyApp global object with the following structure (attached). If you expand app you will see the class name of the controller listed in an array under _controllers. The line that causes this error in my spec file is:
var myView = new MyApp.view.someViewName({ renderTo: 'test' });
I modeled my setup after a few tutorials, one of which is Sencha's https://docs.sencha.com/extjs/4.2.5/#!/guide/testing
(wish there was one for a recent version of Touch). I think my problem may be related to this note midway down that page:
Note: this Application definition is not a copy and paste of your
regular Application definition in your app.js. This version will only
include the controllers, stores, models, etc and when launch is called
it will invoke the Jasmine tests.
It may be related, but I also couldn't follow their:
ctrl = newMyApp.controller.MyController();
where I would get this error:
TypeError: app.getRouter is not a function at Ext.define.applyRoutes (http://localhost:8080/touch/sencha-t...ug.js:45800:26)
Instead, I had to add in this argument like this:
var ctrl = new Kaacoo.controller.loginController({ application : app });
Additionally, my launch file is set up like this:
Ext.require('Ext.app.Application');
Ext.Loader.setConfig({
enabled: true,
disableCaching: true
});
Ext.Loader.setPath('MyApp', '../../app');
// this file is a couple levels deep from the root of my project
Ext.application({
name : 'MyApp',
extend: 'MyApp.Application',
autoCreateViewport: true,
controllers: [
'loginController'
],
requires : [
],
launch: function() {
// Jasmine is bootstrapped with boot.js referenced in the html runner, so nothing here. My test specs are being called after this launch function is executed.
}
});
The order I have listed my resources in my html runner are: Jasmine Library with boot.js> Touch All Debug Library > Project Source Files > Spec Files > Launch file
Building and simulating the app is fine, so why can't I also have access to MyApp.app.getController('loginController') as well in my test environment?
Thanks!
I am using a hybrid app and writing tests using Appium + Selenium Webdriver in Ruby.
I start my test with some textbox editing + click a button to open the UIWebview (so far everything works). The problem is when the UIWebview is opened - I cannot access it (it is immediately closed when I'm trying to click a html element (I am using Appium inspector to find elements and to record my Ruby test). I understand that I have to switch to the UIWebview (as I found here), but I cannot make it to work.
Code example:
require 'rubygems'
require 'selenium-webdriver'
capabilities = {
'browserName' => 'iOS',
'platform' => 'Mac',
'version' => '7.1',
'device' => 'iPhone Retina (4-inch)',
'app' => '/Users/{my user here}/Library/Developer/Xcode/DerivedData/{path here}/Build/Products/Debug-iphonesimulator/SDK.app'
}
server_url = "http://127.0.0.1:4723/wd/hub"
#wd = Selenium::WebDriver.for(:remote, :desired_capabilities => capabilities, :url => server_url)
# ...
# Do all kind of native actions here
# ...
#wd.find_element(:name, "showWebviewButton").click
#wd.manage.timeouts.implicit_wait = 30 # seconds
# ???
# How do I switch to my UIWebview here???
# (cannot access html elements here with #wd.find_element(:name, "htmlElement"))
# ???
#wd.quit
EDIT:
Using Appium inspector I found that my UIWebview is "window(1) ", so I tried:
#wd.switch_to.window(1)
This gives me the error:
A request to switch to a different window could not be satisfied because the window could not be found
(The error is thrown before the UIWebview is loaded)
It seems , you are switching to WebView before it loads. Please pause the script for some time and then switch to the WebView after it appears.
I have tried the following in java and worked fine for me, you may need to find the ruby version of the same.
driver.switchTo().window("WEBVIEW");
try this
#wd.switch_to.window("WEBVIEW") // i am not sure about the syntax
You need to access the element as shown below
findElement(By.xpath("//input[#name='firstName']"))
The only solution that finally worked for me (using Appium 1.2) is (taken from here, written in node.js)
// javascript
// assuming we have an initialized `driver` object for an app
driver
.contexts().then(function (contexts) { // get list of available views. Returns array: ["NATIVE_APP","WEBVIEW_1"]
return driver.context(contexts[1]); // choose the webview context
})
// do some web testing
.elementsByCss('.green_button').click()
.context('NATIVE_APP') // leave webview context
// do more native stuff here if we want
.quit() // stop webdrivage
In the above link you could find the solution written in other languages.
Problem
My controller is not being found when I create the controller using module.controller(). I get the following exception:
Error: Argument 'HelpCtrl' is not a function, got undefined
Detail
I am refactoring my controllers.js file, breaking out each controller into its own separate file. I'm doing this by doing the following:
A typical controller
'use strict';
angular.module('idalinkApp')
.controller('HelpCtrl', function(){
//insert awesome controlling code here
});
My application.js's bootstrap module is the same as the module name above' idalinkApp:
var idalinkModule = angular.module('idalinkApp', [ 'idalinkResources', 'idalinkFilters',
'idalinkDirectives', 'ngSanitize','ui','memberService', 'formStatusService' ]);...
And here's my ng-app declaration in my index.html page:
... <body id="ng-app" data-ng-app="idalinkApp" class=" login idalink-todo idalink-hide idalink-altnav releaseOne"> ...
I've also confirmed that the help.js file containing my HelpCtrl is being loaded in the browser.
Plea
Any ideas?