Hi, I'm working my way through the PhoneBook example. I'm creating an entity named "OnyxClient". However, I'm stuck with the "_CreateOnyxClientModal.js" throwing this error: Uncaught TypeError: Cannot read property 'createOnyxClient' of undefined.
Screen shot is attached.
I realise this is a newbie question, but any directions on how to move forward are much appreciated!
5 Answer(s)
-
0
Hi,
Can you share the definition of "_onyxClientService" in your js file and your App Service class as well ?
Thanks.
-
0
Hi,
This is my .js (_CreateOnyxClientModal.js)
(function () { app.modals.CreateOnyxClientModal = function () {
var _modalManager; var _onyxclientService = abp.services.app.onyxclient; var _$form = null; this.init = function (modalManager) { _modalManager = modalManager; _$form = _modalManager.getModal().find('form'); _$form.validate(); }; this.save = function() { if (!_$form.valid()) { return; } var onyxclient = _$form.serializeFormToObject(); _modalManager.setBusy(true); _onyxclientService.createOnyxClient(onyxclient).done(function () { _modalManager.close(); location.reload(); }).always(function () { _modalManager.setBusy(false); }); }; };
})(jQuery);
And this is OnyxClientAppService.cs
using Abp.Application.Services.Dto; using Abp.AutoMapper; using Abp.Collections.Extensions; using Abp.Domain.Repositories; using Abp.Extensions; using Sixoclock.Onyx.Entities; using Sixoclock.Onyx.OnyxClients.Dto; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks;
namespace Sixoclock.Onyx.OnyxClients { public class OnyxClientAppService : OnyxAppServiceBase, IOnyxClientAppService { private readonly IRepository<OnyxClient> _onyxclientRepository;
public OnyxClientAppService(IRepository<OnyxClient> onyxclientRepository) { _onyxclientRepository = onyxclientRepository; } public ListResultDto<OnyxClientListDto> GetOnyxClients(GetOnyxClientsInput input) { var onyxclientss = _onyxclientRepository .GetAll() .WhereIf( !input.Filter.IsNullOrEmpty(), p => p.Name.Contains(input.Filter) || p.EmailAddress.Contains(input.Filter) ) .OrderBy(p => p.Name) .ToList(); return new ListResultDto<OnyxClientListDto>(ObjectMapper.Map<List<OnyxClientListDto>>(onyxclientss)); } public async Task CreateOnyxClient(CreateOnyxClientInput input) { var onyxclient = input.MapTo<OnyxClient>(); await _onyxclientRepository.InsertAsync(onyxclient); } }
}
I've used the example and replaced "person" with onyxclient and "Person" with "OnyxClient". "People" became "OnyxClients".
Thanks
-
0
Hi,
I think the problem is here
var _onyxclientService = abp.services.app.onyxclient;
Probably value of "abp.services.app.onyxclient" is undefined. Can you write it to Chrome's javascript console "abp.services.app.onyxclient" and execute it there to see it's value ? Changing it to "abp.services.app.onyxClient" might work.
Thanks.
-
0
Good catch, this solved my issue. Thanks.
-
0
Great :)