Version 1.6.0 token input is not allowing custom entry - jquery-tokeninput

In rails project, i am trying to implement jquery token input (version 1.6.0) plugin.
According to the below code, token input is not allowing custom entry. It will select the value which is only in list.
Eg:
jQuery("#text_box_id").tokenInput(go_to_url, {
tokenLimit: 20,
allowCustomEntry: true,
preventDuplicates: true
});

What custom entry do you require? If you want the value the user has entered, you could manually add this value to the json object that you return to jquery-tokeninput success callback.

Related

I am not able to bind the datepicker value with my calling function in angular2.

I have used a JQuery date-picker. The error coming while i am selecting date is:
"(MySelectedDate) does not conform to the required format, "yyyy-MM-dd""

Angular 4 - BehaviourSubject not returning json data properly

I'm trying to creating a global service in angular app with BehaviorSubject.
I have created a method in this service where I have defined a HTTP get method and loading JSON file.
Now the issue I'm facing is when I'm subscribing this BehaviourSubject as asObservable in any component and assign the result to a particular variable in the typescript file, the HTML template renders this value correctly via structured Directive *ngFor but when I'm trying to get the same value in typescript file, it does not work.
For example;
When I'm trying to print this value
console.log(this.data.boxes.length);
then it gives me an error
[ERROR TypeError: Cannot read property 'length' of undefined]
and when I'm trying to print this value without length
console.log(this.data.boxes);
it gives me a proper value of an array in the console panel.
Now If I change BehaviorSubject to Subject, then its working fine means I am also getting length value.
However, I want to use BehaviorSubject instead of Subject.
What am I doing wrong and how can I achieve it?
Behavior subject is emitting current value to subscriber even if subject next is not called before subscription, in other words:
yours subscription is subscribed to subject before first "next" value. I assume that initial value of behavior subject is undefined or similar, so that first value that is emitted to subscriber is causing error.
Could you check declaration of subject and ensure that initial value is in correct form, like:
public exampleSubject = new BeahviourSubject<yourType[]>(<yourType[]>[]);

Field value fetch when field name is not known

I am using a form builder using which my admin side can create forms and store it as JSON. They are rendered dynamically when the client accesses these forms. When the client submits the form at the back end I need to get the value of all the fields.
Currently I am trying to do this as follows:(Node Server)
router.post('/increase', function (req, res, next) {
req.session.counter++;
var ans = req.body;
console.log(ans+" this got printed");
res.redirect('docfill');
});
I cannot specify a name after req.body as i dont know the field name due to the dynamic nature of the forms.
The console prints [Object object]. The currently rendered form has a date field I need. And if I put it through JSON.stringify() it prints {}. Is my fetched data coming out to be blank? Could it be a problem with using the data field.
EDIT
its not because the filed is a date type, dosnt work with text either
There could be 2 reasons for this:
You have not installed/required the bodyParser module.
In your form tag you're using the enctype attribute as enctype="multipart/form-data". Reason for this being you're not using any module for handling the multipart/form-data type which is unreadable by the browser. Use enctype="application/json" instead.

Umbraco razor template - Get Formatted Date From Field specified in parameter

I'm trying to return a formatted date from a razor template in umbraco. I'm not sure how to get a value from a field defined in a parameter though.
Here is the code I'm playing with. The field I'm passing in is called "articleDate". I'm getting the parameter value output, however when I try to get the value of the field using the parameter name it returns nothing. If I ask for the value by the field name itself, that works. How can I create a generic macro like this?
#{var param = #Parameter.dateField;}
Field Name: #param
<br/>
Field Value: #Model.param
<br/>
Field Value: #Model.articleDate
I tried using #Model.GetDynamicMember(..) as well, but that just throws an exception.
Field Value: #Model.GetDynamicMember("articleDate");​
Error loading Razor Script getDate.cshtml
Cannot invoke a non-delegate type
Can someone point me in the right direction? I'm just trying to create a simple macro I can use to format dates across my page.
Is it possible to pass the value of my date directly into the razor macro? This is how I'm currently calling it:
<umbraco:Macro ID="Macro1" Alias="getDate" dateField="articleDate" runat="server"></umbraco:Macro>
If you call your Macro like you wrote:
<umbraco:Macro ID="Macro1" Alias="getDate" dateField="articleDate" runat="server"></umbraco:Macro>
You're actually passing the name of the field "articleDate". In the macro, you then may get the value of the Model's articleDate property by using:
Field Value: #Model.getProperty(Parameter.dateField).Value
Instead of macro's I also recommend using helpers or - for more complex scripts - RenderPage. A nice writeup can be found here:
http://joeriks.wordpress.com/2011/03/11/better-structure-for-your-razor-scripts-with-renderpage-in-umbraco/
Example:
#helper GetDate(dynamic dateField)
{
#dateField.ToString("[yourFormat]")
}
You may pass parameters to scripts rendered with RenderPage by using the Page object:
<umbraco:macro language="razor" runat="server">
#{
Page.dateField=Model.articleDate;
}
#RenderPage("~/macroscripts/getdate.cshtml")
</umbraco:macro>
getdate.cshtml:
#Page.datefield.ToString("[yourFormat]")

Populate plugin not working correctly

Hi i'm trying to retrieve and populate a form. The following link with username Testing and password test123 .
The page is returning a correct JSON object (I tested it by putting on screen between paragraph tags) but the populate plugin is not populating. In firebug it show "no such element as" without displaying the element's name. The input field names are exactly the same is in the DB.
any ideas?
The problem is that your success callback gets passed a string argument, instead of the expected Object/Array, which causes the populate method to treat the whole input as a single unnamed value. This is caused by a typo in the options object passed to your $.ajax() call:
$.ajax({
// ...
datatype: 'json'
});
The option names are case sensitive and the correct spelling for the datatype attribute is dataType with a capital tee. By default, if the datatype option is missing/misspelled, jQuery will try to intelligently guess the datatype of the response and return the result as a formatted string (see the jQuery documentation). So just rename the datatype option to dataType and your fields get populated correctly.