Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with templates methods #93

Closed
KerMiiTT opened this issue Aug 30, 2016 · 6 comments
Closed

Problem with templates methods #93

KerMiiTT opened this issue Aug 30, 2016 · 6 comments
Labels

Comments

@KerMiiTT
Copy link

  • Vue.js version: 1.0.26
  • techno: MVC4, C#4.5

Hi,

I have a problem when i call a methods on template options.

templates: { Action: "<a href='#!' @@click='$parent.deleteDocument({Name})'><i class='material-icons'>delete</i></a>" },

When i passed an int in {Name} my method is called, but when i try with a string the method did not call.

n.b: i use double @@click because i use razor asp.net and it work with an other method.
do you an issue for my problem ?

@matfish2
Copy link
Owner

matfish2 commented Aug 30, 2016

You need to wrap Name with double quotes so it will be interpreted as a
string. The way it is now it is interpreted as a variable name

@KerMiiTT
Copy link
Author

thank you for your quick response

so like this : "<a href='#!' @@click='$parent.deleteDocument({{Name}})'><i class='material-icons'>delete</i></a>" ?

@KerMiiTT
Copy link
Author

KerMiiTT commented Aug 30, 2016

i have tried with this :
'<a href="#!" @@click="$parent.deleteDocument("{Name}")"><i class="material-icons">delete</i></a>'

and my methods is deleteDocument: function (data) { console.log("OK delete" + data); }
but it doesn't word

i try to change with <a href="#!" @@click="$parent.deleteDocument("test")">delete
and it same

@KerMiiTT
Copy link
Author

i have tried on your live demo https://jsfiddle.net/matfish2/f5h8xwgn/

i have changed the {id} by 'test' delete: "<a href='javascript:void(0);' @click='$parent.deleteMe('test')'><i class='glyphicon glyphicon-erase'></i></a>"
it's same, it doesn't work, what's wrong ?

@matfish2
Copy link
Owner

matfish2 commented Aug 30, 2016

You already used single quotes to wrap the click expression. You can't use them again within this expression without escaping or concatenating. (In your previous comment you had the same problem with double quotes). This WILL work:

"<a href='javascript:void(0);' @click='$parent.deleteMe(" + '"test"' +")'><i class='glyphicon glyphicon-erase'></i></a>"

@KerMiiTT
Copy link
Author

thank you very much for your answer , it works perfectly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants