Meteor - Binding to element on initial template render throws error - meteor

I am using Meteor, FlowRouter, and Parsley for validation. When I reload the app and enter into the page with the form, I get this error and parsley is not working on the form:
You must bind Parsley on an existing element.
If I leave the page and come back, it works fine. I have the following code initializing the binding:
Template.report.onRendered ->
report = Reports.findOne(_id: FlowRouter.getParam('reportId'))
if report.status == 'finalized'
Session.set('showDistributeReport', true)
else
Session.set('showDistributeReport', false)
$('#status-js').val(report.status)
$('#report-form-js').parsley()
I have been using Parsley and haven't seen this problem on other pages. Any help would be greatly appreciate.

I figured out a fix but I'm not sure why I had to do this. If anyone has any input that would be great. I had to take the portion where I set the session variable and move it to the onCreated method. This is the code I have now.
Template.report.onCreated ->
report = Reports.findOne(_id: FlowRouter.getParam('reportId'))
if report.status == 'finalized'
Session.set('showDistributeReport', true)
else
Session.set('showDistributeReport', false)
Template.report.onRendered ->
report = Reports.findOne(_id: FlowRouter.getParam('reportId'))
$('#status-js').val(report.status)
$('#report-form-js').parsley()

Related

symfony2 cannot read property 'fnIsDatatable' of undefined

I'm desperate because I don't find any solution on web for my problem.
I work with easytabs, and on every tab I have a different DataTable with different IDs. On page loading, I've to check, if a DataTable is still there.
On localhost everything works fine, but when i push it on the server I get the following error message:
Uncaught TypeError: Cannot read property 'fnIsDataTable' of undefined
My Code:
if ($.fn.dataTable.fnIsDataTable('#table-history')) {
$('#table-history').DataTable().destroy();
}
I can't explain why it is working on localhost, and any suggestions like "You've to load the jquery before datatable js file" don't solve this issue.
I hope you have any suggestions or experience with it.
Hope this help for you.
As #Eliellel said over here ,What you are trying is : trying to destroy datatable before its creation.
try to replace your function with mine.
if ($.fn.dataTable.fnIsDataTable('#table-history')) {
var table = $('#table-history').DataTable();
if(table){
table.destroy();
}
}

Xamarin Forms - Native Forms

I am trying to experiment with Native Forms in XF. I have this in iOS working right. That is fine.
In Android, I am getting the following error:
'MainPage' does not contain a definition for 'CreateSupportFragment' and the best extension method overload 'PageExtensions.CreateSupportFragment(ContentPage, Context)' requires a receiver of type 'ContentPage'
The code is erroring in the following code:
var _cp = new MainPage(); // my page from XF.
_list = _cp.CreateSupportFragment(this);
I have made sure that my nuget packages are up to date. I have cleaned and compiled. I've done a bunch of things, but alas, no love. Any ideas on this?
TIA
you need add the line to head of source:
using Xamarin.Forms.Platform.Android
because CreateSupportFragment is an extension method defined in it.

SAPUI5 / OpenUI5 Databinding for Custom Controls

I'm working with SAPUI5 and OpenUI5. I'ved developed some custom controls for now but never used the 2-Way Databinding for this controls...I've tried it with
oMyControl.bindProperty("someValue", "oModel>/testBindingValue")
What I've seen is: When watching the Model in the debugger the field aBindings have one entry:
sPath: "/testBindingValue"
sInternalType: "int"
and the correct sInternalType of my Controls property type (in this case "int").
But when I'm watching the array oModel.oData it is empty and oModel.getProperty("/testBindingValue")
is also returning undefined...but my control definitely has a value for "someValue"...So, does anyone have an idea?
Thanks,
Alex
UPDATE:
Here you see my workflow:
first creating the model:
var oModel = new sap.ui.model.json.JSONModel();
sap.ui.getCore().setModel(oModel, 'oModel');
then initializing my control:
var oMyControl = new MyControl({
someValue: "Test Value of the Control"
});
oMyControl.bindProperty("someValue", "oModel>/testValue");
Now, when I'm doing:
alert(oModel.getProperty("/testValue"));
I will get "undefined".
So, for normal controls this is working, for "value", "text", "visible" or "enabled" and so on..
I'm guessing there is something in your custom control that is making this not work correctly. I have created an example of what I understand you are doing (http://jsbin.com/kiwoza/2/edit?html,console,output) and it seems to work as I'd expect. If this example is somehow different from what you're trying to accomplish please update the question with details about why it's not quite right.

ASP.Net Dropdown List is not throwing an error

I am having problems with dropdown lists NOT throwing an error with the following code in ASP.Net 4.0
the dropdown list is empty to start. The page in question is a simple test page containing no code besides the lines below in Page_Load.
ddlTest.Items.Add(new ListItem("test","test"));
ddlTest.SelectedValue = "Fail";
When I load the page, the DDL displays "test" as the only item (as expected) and no error is thrown. I thought an error would be thrown with something like "item 'Fail' does not exist"
I have tested the code both, inside an if (!IsPostBack) block and outside of it. The results are the same.
Does this make sense? I don't understand why this is not throwing an error. Any explanation would be greatly appreciated.
Thanks.
It will only throw an exception if there are no items in ddlTest, otherwise it just doesn't find the value.
You can always do this first if you are trying to find out if the item exists in the list:
if (ddlTest.Items.FindByValue("Fail") != null)
ddlTest.SelectedValue = "Fail";
else
//item doesn't exist, do something meaningful here

Highlighting the current Step in a multi step form page

i am using a simple form page with 4 steps in it i am not using any wizard control for this i want to highlight the current step what i have to do for achieving this functionality.
if (WhateverPanel.Visible == true) {
StepLabel.BackColor = System.Drawing.Color.WhateverYouWant;
}
Or for labels it might be
StepLabel.Styles.BackColor = ...
I have to get to work or I'd check. Regardless, put that in the Page_Load and you should be gravy.

Resources