Can't open new window when click button - javascript

I need to redirect to new window by using onclick openNewWindow . I just route to my controller but seems it give error as "Route [sla.slaCategoryTreeListScreen] not defined"
Here is my controller code.
public function slaCategoryTreeListScreen() {
return view('sla.slm.SLACategoryCheckBoxList');
}
my view onclick part
<a class="btn btn-sm btn-default pull-right" type="button" title="Search Category" onclick="openNewWindow('{{ route('sla.slaCategoryTreeListScreen') }}" >
my route
Route::group(['prefix' => 'sla'], function () {
Route::resource('sla', 'SlaController');
//Route::get('sla','SlaController#slaCategoryTreeListScreen')->name('SlaController.slaCategoryTreeListScreen');
// Route::get('sla','SlaController#SlaCategoryTreeListScreen')->name('sla.SlaCategoryTreeListScreen');
Route::get('sla/getbranch/{id}','SlaController#getBranchAjax')->name('sla.getBranchAjax');
Route::get('sla/getBranchAjax2/{cuid}/{stid?}','SlaController#getBranchAjax2')->name('sla.getBranchAjax2');
});
The comment part on route that are trying was not fix at all..Sorry for my bad English and i hope its help.

First of all: Route::resource() does only register routes by a predefined array of defaults ('index', 'create', 'store', 'show', 'edit', 'update', 'destroy').
It will not automatically register any method from your controller.
Also make sure that your controller has methods for all these routes or specify a subset of routes. Check this for more information: https://laravel.com/docs/6.x/controllers#restful-partial-resource-routes
Second: Your a-tag seems to be malformed. The JavaScript method opens with (' but is never closed again. So it should be like this:
onclick="openNewWindow('{{ route('sla.slaCategoryTreeListScreen') }}')"
To simply open the URL in a new tab you could use this (with target="_blank"):
Search Category
Additionally: make sure that a route named sla.slaCategoryTreeListScreen exist. Easiest way to do so is by listing all available routes by running the command php artisan route:list from the root directory of your project in a terminal.

Replace this in your view file
<a class="btn btn-sm btn-default pull-right" type="button" title="Search Category" onclick="window.open('{{ route('sla.SlaCategoryTreeListScreen') }} ', '_blank')" >

Related

How to add a new webpage to ASP.NET MVC

Right now I am making a MVC that has a default page that loads up. From this page, the user can press a button to go to the next page. So far, I have made the first page work and a button that goes to a specified URL for the second page. The only issue I am having is making the view that I want to correspond to the second page have the correct URL.
Here is the code for my button link to the next URL
<input type="button" value="Create" onclick="location.href='#Url.Action("IndexA", "HomeController")'" />
I guess my question is how do I make my view have the specified URL that I want so it can be accessed?
I used something like this in my own project.
#if (Request.UrlReferrer != null && Request.UrlReferrer.Host == Request.Url.Host)
{
<a href="#Request.UrlReferrer" class="dbtn btn-11">
<i class="fa fa-undo"></i>
#Resources._Action_Back
</a>
}
only came from within the domain that was published I said let the button appear.
there is something like add controller in default settings controller name + controller. So just write the name there.
I had to put "home" in the URL.Action instead of "HomeController"
Please see this photo.
https://ibb.co/4SS5nYh
You add a new controller and a new view for that new page (also a model). I have called mine Test.
Then in the button. you call them with url action.
<input type="button" value="Create" onclick="location.href='#Url.Action("Index", "Test")'" />

"Could not parse reminder error" - django

When jsevent triggered , it forwards link parameter to data-url attribute of a button and when user click that button it redirects to django backend view but there is a problem with parsing line of JS
$('#btn_del').attr('data-url',{% url 'event_delete' + event.id + %});
is there any chance to combine that syntax ?
Thank you , have a nice days.
JS:
eventClick: function(event, jsEvent, view) {
$('#modalTitle').html(event.id);
$('#btn_del').attr('data-url',`{% url 'event_delete' ` + event.id + `%}`);
$('#calendarEditModal').modal();
console.log(event.id);
}
url.py
....
url(r'^event/(?P<pk>\d+)/delete/$', event_delete, name='event_delete'),
....
Html button that redirects to django
<button id="btn_del" type="button" class="btn btn-primary js-delete-events" data-url="">
<span class="glyphicon glyphicon-pencil"></span>
Edit
</button>
Result should be like this format event.pk is going to be our parameter numeric value , it's ok.
<button type="button" class="btn btn-primary js-delete-events" data-url="{% url 'event_delete' event.pk %}">
<span class="glyphicon glyphicon-plus"></span>
button
</button>
/event/1/update/ is the last result of seen from browser inspect. But I need to write inside jsEvent with django syntax to able to reach backend view which is {% url 'event_delete' event.pk %} something like that.
No, it cannot be done that way... Parsing of your templates (the {% url %} tag) is done on the server before even the browser receives anything. Browser doesn't know what template tags are you using.
On the other side, JavaScript is executed in the browser, so template language has also no knowledge about variables inside it.
Solution for that is to use a package like Django JS Reverse. The second one is to pass full URL to the JavaScript, just like it receives the ID of the item.

how to add dialog box in with yes or no option and call function based on that

I am new to typescript/angular project and working on one project. In .html file i am calling delete operation but i want to add extra confirmation for delete operation. My existing code is :
<a (click)="onUserDelete()" class = "btn btn-danger" >Delete User</a>
How to add conditional check and call 'onUserDelete()' function whic is define in .ts file.
I tried adding but it always throws error.
Tried code:
<script type="text/javascript">
function UserDelete(){
onUserDelete();
}
</script>
<a (click)="UserDelete()" class = "btn btn-danger" >Delete</a>
It always throws UserDelete is not a function.
Make your ts file function for global access and then use it with
window.angularComponentRef.zone.run(function () {
window.angularComponentRef.componentFn(10)
})
Use NgZone for accessing function from outside.
For more info you can follow: Angular2 - how to call component function from outside the app

How to concatenate two params using href?

I have kendo grid where i am using anchor tag so using href i am trying to pass two params from client side but it always give syntax error, any help what is correct way to pass variables using href.
config.js
toolbar: [{template: '<a class="btn btn-default btn-sm pull-right"
href="app/challenge/rest/exportChallengeGridDataToExcel?key={{$rootScope.id}}
&challengeType={{$rootScope.challengeType}}">Export to Excel</a>'}]
You can do something like :
'<a class="btn btn-default btn-sm pull-right"
href="app/challenge/rest/exportChallengeGridDataToExcel?key={{$rootScope.id}}
&challengeType={{$rootScope.challengeType}}">Export to Excel</a>
Anyways I would encourage you to use $rootScope as less as possible, also to build your URL in your controller so your html looks more readable, but that's up to you

FlowJS example to loop through files in Angular controller

Does anyone have an example on how to access the $flow object in an angularJS controller? I need to iterate through the files after the end user clicks a submit button before they're uploaded.
I've tried passing the $flow object from the front end...
<button class="btn btn-success btn-block" type="button" ng-click="ok($flow)">Save Submission</button>
And attempting to access it from the back end directly...
angular.forEach($scope.$flow.files, function (file, index) {
// do something
}
The $flow object is always undefined.
We have had trouble accessing $flow in $scope as well (though in theory that should work), so I recommend setting the following on the DIV:
<div flow-name="uploader.flow" ...> </div>
Then you can access in the Angular controller via something like the following:
$scope.uploader.flow.files[i].

Categories